Skip to content

Commit 2ce523d

Browse files
committed
FIX: don't silently ignore leading zero byte in the der codec data
1 parent 811d229 commit 2ce523d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/mezz/codec-der.reb

+11-7
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ register-codec [
2929
wl: length? form length? data
3030
wr: negate wl
3131
]
32-
if data/1 <> 48 [
33-
if verbose > 0 [
34-
prin "*** DER data does not start with SEQUENCE tag ***^/*** "
35-
probe copy/part data 10
32+
33+
case [
34+
all [data/1 = 0 data/2 = 48][data: next data]
35+
data/1 <> 48 [
36+
if verbose > 0 [
37+
prin "*** DER data does not start with SEQUENCE tag ***^/*** "
38+
probe copy/part data 10
39+
]
40+
return none
3641
]
37-
return none
3842
]
3943

4044
der: binary data
@@ -118,12 +122,12 @@ register-codec [
118122
;data: none
119123
;]
120124
BIT_STRING [
121-
if data/1 = 0 [data: next data]
125+
;@@if data/1 = 0 [data: next data]
122126
;data: enbase data 2
123127
]
124128
INTEGER [
125129
;@@ TODO: review if the null skipping is correct!
126-
if data/1 = 0 [data: next data]
130+
;@@if data/1 = 0 [data: next data]
127131
]
128132
]
129133
if data [

0 commit comments

Comments
 (0)