}
size_t bytesNeeded = descriptor < Value8Bit ? 0 : (1 << (descriptor - Value8Bit));
- if (it->ptr + 1 + bytesNeeded > parser->end)
+ if (bytesNeeded + 1 > (size_t)(parser->end - it->ptr))
return CborErrorUnexpectedEOF;
uint8_t majortype = type >> MajorTypeShift;
err = extract_length(value->parser, &ptr, &total);
if (err)
return err;
- if (ptr + total > value->parser->end)
+ if (total > (size_t)(value->parser->end - ptr))
return CborErrorUnexpectedEOF;
if (total <= *buflen)
*result = func(buffer, ptr, total);
if (unlikely(add_check_overflow(total, chunkLen, &newTotal)))
return CborErrorDataTooLarge;
- if (ptr + chunkLen > value->parser->end)
+ if (chunkLen > (size_t)(value->parser->end - ptr))
return CborErrorUnexpectedEOF;
if (*result && *buflen >= newTotal)