Currently code won't work with them because of the uint64 overflow.
((l < (1 << 16)) && (ll > 2))) {
return YACErrLenNonMinimal;
}
+ if (l > ((uint64_t)(1) << 60)) {
+ return YACErrLenTooBig;
+ }
}
atom->off += l;
if (len < atom->off) {
if (atom->typ == YACItemStr) {
size_t cpl = 0;
uint32_t cp = YACUTF8InvalidCp;
- for (ll = 0; ll < l;) {
- cpl = YACUTF8CpDecode(&cp, atom->val.buf + ll, l - ll);
+ for (size_t n = 0; n < l;) {
+ cpl = YACUTF8CpDecode(&cp, atom->val.buf + n, l - n);
if (cp == YACUTF8InvalidCp) {
return YACErrBadUTF8;
}
- ll += cpl;
+ n += cpl;
}
}
return YACErrNo;
YACErrNotEnough, // not enough data (atom.off is how much)
YACErrUnknownType, // unknown atom's type
YACErrLenNonMinimal, // non-minimal string length coding
+ YACErrLenTooBig, // string length >1<<60
YACErrBadUTF8, // invalid UTF-8 codepoint
YACErrIntZeroByte, // non-minimal integer coding
YACErrIntNonMinimal, // non-minimal integer coding
var (
ErrNotEnough = errors.New("not enough data")
ErrLenNonMinimal = errors.New("non-minimal len")
+ ErrLenTooBig = errors.New("string len >1<<60")
ErrIntZeroByte = errors.New("zero byte int")
ErrUnknownType = errors.New("unknown type")
ErrBadUTF8 = errors.New("invalid UTF-8")
err = ErrNotEnough
return
}
- l = int(FromBE(buf[1 : 1+ll]))
+ ul := FromBE(buf[1 : 1+ll])
+ if ul > (1 << 60) {
+ err = ErrLenTooBig
+ return
+ }
+ l = int(ul)
if (l < 61) || ((l < (1 << 8)) && (ll > 1)) || ((l < (1 << 16)) && (ll > 2)) {
err = ErrLenNonMinimal
return