iemejia commented on code in PR #3859:
URL: https://github.com/apache/avro/pull/3859#discussion_r3567500451
##########
lang/c++/impl/BinaryDecoder.cc:
##########
@@ -177,9 +242,27 @@ size_t BinaryDecoder::skipArray() {
for (;;) {
auto r = doDecodeLong();
if (r < 0) {
- auto n = static_cast<size_t>(doDecodeLong());
- in_.skipBytes(n);
+ auto byteSize = doDecodeLong();
+ if (byteSize < 0) {
+ // A negative block byte-size would convert to a huge size_t
and
+ // drive an unbounded skip; reject it.
+ throw Exception("Invalid negative block size: {}", byteSize);
+ }
+ in_.skipBytes(static_cast<size_t>(byteSize));
Review Comment:
Fixed — the negative-block byte-size now gets the same `if constexpr
(sizeof(size_t) < sizeof(int64_t))` fit guard before the cast, and
`checkAvailableBytes(byteSize)` is called before skipBytes(), so a too-large or
truncated block is rejected instead of being silently skipped past EOF.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]