aboutsummaryrefslogtreecommitdiff
path: root/ber
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-06-26 20:18:06 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-06-26 20:18:06 +0200
commitd9fb582cb9748e2f98e4ddb0471bdb037ea4f050 (patch)
treeee5c71c62efcc13559308c5a91c4eea14f5411a7 /ber
parent2864729d325aa13bd8591536185bf09bc0505bfa (diff)
Boundary check
Diffstat (limited to 'ber')
-rw-r--r--ber/obj.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/ber/obj.go b/ber/obj.go
index f2e76d1..a8b590e 100644
--- a/ber/obj.go
+++ b/ber/obj.go
@@ -2,7 +2,7 @@ package ber
func base128(n int) (b []byte) {
if n == 0 {
- return []byte{0x00}
+ return []byte{0}
}
l := 0
for i := n; i > 0; i >>= 7 {
@@ -24,6 +24,12 @@ func debase128(b []byte) int {
}
func marshalObj(obj []int) (b []byte) {
+ if len(obj) < 2 {
+ return []byte{}
+ }
+ if obj[0] < 2 && obj[1] > 39 {
+ return []byte{}
+ }
first := obj[0]*40 + obj[1]
b = append(b, base128(first)...)
for _, o := range obj[2:] {