@@ -22,6 +22,7 @@ import (
22
22
"bytes"
23
23
"encoding/binary"
24
24
"fmt"
25
+ "math"
25
26
"reflect"
26
27
"strconv"
27
28
"strings"
@@ -295,6 +296,9 @@ func readVarUint(data []byte, info *fieldInfo) (uint64, error) {
295
296
if info == nil || ! info .countSet {
296
297
return 0 , structuralError {info .fieldName (), "no field size information available" }
297
298
}
299
+ if info .count > math .MaxInt {
300
+ return 0 , syntaxError {info .fieldName (), "count > math.MaxInt" }
301
+ }
298
302
if len (data ) < int (info .count ) {
299
303
return 0 , syntaxError {info .fieldName (), "truncated variable-length integer" }
300
304
}
@@ -365,6 +369,9 @@ func parseField(v reflect.Value, data []byte, initOffset int, info *fieldInfo) (
365
369
return offset , err
366
370
}
367
371
v .SetUint (val )
372
+ if info .count > math .MaxInt {
373
+ return offset , syntaxError {info .fieldName (), "count > math.MaxInt" }
374
+ }
368
375
offset += int (info .count )
369
376
return offset , nil
370
377
case reflect .Struct :
@@ -468,7 +475,13 @@ func parseField(v reflect.Value, data []byte, initOffset int, info *fieldInfo) (
468
475
if err != nil {
469
476
return offset , err
470
477
}
478
+ if varlen > math .MaxInt {
479
+ return offset , syntaxError {info .fieldName (), "varlen > math.MaxInt" }
480
+ }
471
481
datalen := int (varlen )
482
+ if info .count > math .MaxInt {
483
+ return offset , syntaxError {info .fieldName (), "count > math.MaxInt" }
484
+ }
472
485
offset += int (info .count )
473
486
rest = rest [info .count :]
474
487
0 commit comments