iemejia commented on code in PR #3842:
URL: https://github.com/apache/avro/pull/3842#discussion_r3563801343


##########
lang/c/src/consume-binary.c:
##########
@@ -58,7 +58,11 @@ read_array(avro_reader_t reader, const avro_encoding_t * enc,
 
        while (block_count != 0) {
                if (block_count < 0) {
-                       block_count = block_count * -1;
+                       if (block_count == INT64_MIN) {
+                               avro_set_error("Invalid array block count");
+                               return EINVAL;
+                       }
+                       block_count = -block_count;

Review Comment:
   Fixed — added the same guard after the loop's `read_long()`, before the 
second `array_start_block` call.



##########
lang/c/src/consume-binary.c:
##########
@@ -58,7 +58,11 @@ read_array(avro_reader_t reader, const avro_encoding_t * enc,
 
        while (block_count != 0) {
                if (block_count < 0) {
-                       block_count = block_count * -1;
+                       if (block_count == INT64_MIN) {
+                               avro_set_error("Invalid array block count");
+                               return EINVAL;

Review Comment:
   Fixed — moved the `INT64_MIN` guard to immediately after `read_long()`, 
before the first `array_start_block` callback.



##########
lang/c/src/consume-binary.c:
##########
@@ -101,7 +105,11 @@ read_map(avro_reader_t reader, const avro_encoding_t * enc,
 
        while (block_count != 0) {
                if (block_count < 0) {
-                       block_count = block_count * -1;
+                       if (block_count == INT64_MIN) {
+                               avro_set_error("Invalid map block count");
+                               return EINVAL;
+                       }

Review Comment:
   Fixed — same pattern: `INT64_MIN` check immediately after `read_long()`, 
before `map_start_block`.



##########
lang/c/src/consume-binary.c:
##########
@@ -101,7 +105,11 @@ read_map(avro_reader_t reader, const avro_encoding_t * enc,
 
        while (block_count != 0) {
                if (block_count < 0) {
-                       block_count = block_count * -1;
+                       if (block_count == INT64_MIN) {
+                               avro_set_error("Invalid map block count");
+                               return EINVAL;
+                       }
+                       block_count = -block_count;

Review Comment:
   Fixed — guard added after the loop's `read_long()` as well. Both entry 
points are now protected.



-- 
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]

Reply via email to