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


##########
lang/c/src/value-read.c:
##########
@@ -330,9 +534,19 @@ read_value(avro_reader_t reader, avro_value_t *dest)
                case AVRO_ENUM:
                {
                        int64_t  val;
+                       int  symbol_count;
+                       avro_schema_t  enum_schema;
                        check_prefix(rval, avro_binary_encoding.
                                     read_long(reader, &val),
                                     "Cannot read enum value: ");
+                       enum_schema = avro_value_get_schema(dest);
+                       symbol_count =
+                           avro_schema_enum_number_of_symbols(enum_schema);
+                       if (val < 0 || val >= symbol_count) {

Review Comment:
   Fixed — the AVRO_ENUM case now checks `is_avro_enum(enum_schema)` and 
returns EINVAL for a NULL/non-enum schema before calling 
avro_schema_enum_number_of_symbols(), so a negative error code can't make the 
range check accept out-of-range indices.



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