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