aboutsummaryrefslogtreecommitdiff
path: root/ber/packet.go
diff options
context:
space:
mode:
Diffstat (limited to 'ber/packet.go')
-rw-r--r--ber/packet.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/ber/packet.go b/ber/packet.go
index f244c4e..ea90240 100644
--- a/ber/packet.go
+++ b/ber/packet.go
@@ -1,12 +1,15 @@
package ber
-func Split(b []byte) (c Class, k Kind, t Tag, l int, v []byte, r []byte) {
- var n int
- c, k, t, n = Ident(b)
- b = b[n:]
- l, n = UnmarshalLen(b)
- b = b[n:]
- v = b[:l]
- r = b[l:]
+import "io"
+
+func Split(r io.ByteReader) (c Class, k Kind, t Tag, l int, v []byte) {
+ c, k, t = Ident(r)
+ l = UnmarshalLen(r)
+ if l > 0 {
+ v = make([]byte, l)
+ for i := 0; i < l; i++ {
+ v[i], _ = r.ReadByte()
+ }
+ }
return
}