kwenzh commented on code in PR #3635:
URL: https://github.com/apache/avro/pull/3635#discussion_r2734517427


##########
lang/c/src/avro/io.h:
##########
@@ -52,6 +52,7 @@ avro_reader_memory_set_source(avro_reader_t reader, const 
char *buf, int64_t len
 void
 avro_writer_memory_set_dest(avro_writer_t writer, const char *buf, int64_t 
len);
 
+int64_t avro_max_read(avro_reader_t reader);

Review Comment:
   accept



##########
lang/c/src/encoding_binary.c:
##########
@@ -180,21 +182,30 @@ size_bytes(avro_writer_t writer, const char *bytes, const 
int64_t len)
 static int read_string(avro_reader_t reader, char **s, int64_t *len)
 {
        int64_t  str_len = 0;
+       int64_t  max_available = -1;
        int rval;
        check_prefix(rval, read_long(reader, &str_len),
                     "Cannot read string length: ");
        if (str_len < 0) {
                avro_set_error("Invalid string length: %" PRId64, str_len);
                return EINVAL;
        }
+    //  max := r.tail - r.head + 1; if max >= 0 && size > max

Review Comment:
   accept



##########
lang/c/src/encoding_binary.c:
##########
@@ -136,8 +136,10 @@ static int read_bytes(avro_reader_t reader, char **bytes, 
int64_t * len)
                avro_set_error("Cannot allocate buffer for bytes value");
                return ENOMEM;
        }
-       AVRO_READ(reader, *bytes, *len);
+       
        (*bytes)[*len] = '\0';
+       AVRO_SAFE_READ(reader, *bytes, *len,  *len+1);

Review Comment:
   accept



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