@@ -197,9 +197,6 @@ func TestRoundTripWithEncodePayload(t *testing.T) {
197197 }
198198}
199199
200- // TestExtractPayloadsZeroLength confirms ExtractPayloads accepts a header with
201- // length=0 and that FromSignedPayload rejects the resulting empty payload
202- // rather than panicking.
203200func TestExtractPayloadsZeroLength (t * testing.T ) {
204201 // 4-byte selector + 1-byte protocol + 4-byte votingRound + 2-byte length=0
205202 data := make ([]byte , 4 + 1 + 4 + 2 )
@@ -213,3 +210,21 @@ func TestExtractPayloadsZeroLength(t *testing.T) {
213210 var s submitSignaturesPayload
214211 require .Error (t , s .FromSignedPayload (payloads [0 ]))
215212}
213+
214+ func TestExtractUint16Overflow (t * testing.T ) {
215+ // 4-byte selector + 1-byte protocol + 4-byte votingRound + 2-byte length=0
216+ data := make ([]byte , 4 + 1 + 4 + 2 )
217+ binary .BigEndian .PutUint32 (data [5 :9 ], 1 )
218+ binary .BigEndian .PutUint16 (data [9 :11 ], 0xffff )
219+
220+ _ , err := ExtractPayloads (data )
221+ require .Error (t , err )
222+
223+ dataTrue := make ([]byte , 4 + 1 + 4 + 2 + 0xffff )
224+ binary .BigEndian .PutUint32 (dataTrue [5 :9 ], 1 )
225+ binary .BigEndian .PutUint16 (dataTrue [9 :11 ], 0xffff )
226+
227+ payloads , err := ExtractPayloads (dataTrue )
228+ require .NoError (t , err )
229+ require .Len (t , payloads , 1 )
230+ }
0 commit comments