aboutsummaryrefslogtreecommitdiff
path: root/ber
diff options
context:
space:
mode:
Diffstat (limited to 'ber')
-rw-r--r--ber/obj.go2
-rw-r--r--ber/obj_test.go5
2 files changed, 6 insertions, 1 deletions
diff --git a/ber/obj.go b/ber/obj.go
index a8b590e..ff8aef8 100644
--- a/ber/obj.go
+++ b/ber/obj.go
@@ -24,7 +24,7 @@ func debase128(b []byte) int {
}
func marshalObj(obj []int) (b []byte) {
- if len(obj) < 2 {
+ if len(obj) < 2 || obj[0] > 2 {
return []byte{}
}
if obj[0] < 2 && obj[1] > 39 {
diff --git a/ber/obj_test.go b/ber/obj_test.go
index d8299bb..abe6832 100644
--- a/ber/obj_test.go
+++ b/ber/obj_test.go
@@ -30,4 +30,9 @@ func TestObj(t *testing.T) {
[]byte{0x2B, 0x0C, 0x00, 0x81, 0x5A})
testObj(t, []int{1, 3, 12, 0, 285, 200},
[]byte{0x2B, 0x0C, 0x00, 0x82, 0x1D, 0x81, 0x48})
+ testObj(t, []int{}, []byte{})
+ testObj(t, []int{0, 39}, []byte{0x27})
+ testObj(t, []int{1, 39}, []byte{0x4f})
+ testObj(t, []int{1, 40}, []byte{})
+ testObj(t, []int{2, 40}, []byte{0x78})
}