File tree 2 files changed +19
-1
lines changed 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -813,7 +813,7 @@ func (m *serverHelloMsg) unmarshal(data []byte) bool {
813
813
}
814
814
sctLen := int (d [0 ])<< 8 | int (d [1 ])
815
815
d = d [2 :]
816
- if len (d ) < sctLen {
816
+ if sctLen == 0 || len (d ) < sctLen {
817
817
return false
818
818
}
819
819
m .scts = append (m .scts , d [:sctLen ])
Original file line number Diff line number Diff line change @@ -305,3 +305,21 @@ func TestRejectEmptySCTList(t *testing.T) {
305
305
t .Fatal ("Unmarshaled ServerHello with empty SCT list" )
306
306
}
307
307
}
308
+
309
+ func TestRejectEmptySCT (t * testing.T ) {
310
+ // Not only must the SCT list be non-empty, but the SCT elements must
311
+ // not be zero length.
312
+
313
+ var random [32 ]byte
314
+ serverHello := serverHelloMsg {
315
+ vers : VersionTLS12 ,
316
+ random : random [:],
317
+ scts : [][]byte {nil },
318
+ }
319
+ serverHelloBytes := serverHello .marshal ()
320
+
321
+ var serverHelloCopy serverHelloMsg
322
+ if serverHelloCopy .unmarshal (serverHelloBytes ) {
323
+ t .Fatal ("Unmarshaled ServerHello with zero-length SCT" )
324
+ }
325
+ }
You can’t perform that action at this time.
0 commit comments