martin-g commented on code in PR #3623:
URL: https://github.com/apache/avro/pull/3623#discussion_r2688024435
##########
lang/c/src/datafile.c:
##########
@@ -451,6 +451,10 @@ static int file_read_block_count(avro_file_reader_t r)
"Cannot read file block count: ");
check_prefix(rval, enc->read_long(r->reader, &len),
"Cannot read file block size: ");
+ if (len < 0) {
Review Comment:
Is `len == 0` OK here ?
##########
lang/c/src/datafile.c:
##########
@@ -451,6 +451,10 @@ static int file_read_block_count(avro_file_reader_t r)
"Cannot read file block count: ");
check_prefix(rval, enc->read_long(r->reader, &len),
"Cannot read file block size: ");
+ if (len < 0) {
Review Comment:
What if the read value is positive but again a really big one, like
INT64_MAX ?
##########
lang/c/src/datafile.c:
##########
@@ -451,6 +451,10 @@ static int file_read_block_count(avro_file_reader_t r)
"Cannot read file block count: ");
check_prefix(rval, enc->read_long(r->reader, &len),
"Cannot read file block size: ");
+ if (len < 0) {
+ avro_set_error("Invalid block size: %" PRId64, len);
+ return EINVAL;
+ }
if (r->current_blockdata && len > r->current_blocklen) {
r->current_blockdata = (char *)
avro_realloc(r->current_blockdata, r->current_blocklen, len);
Review Comment:
This is an old code but shouldn't it check that the allocated char* is
non-NULL before assigning it to r->current_blockdata ?
--
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]