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


##########
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:
   enum validation assumes avro_value_get_schema(dest) always returns a valid 
enum schema. If it returns NULL or a non-enum schema (possible for custom value 
interfaces), avro_schema_enum_number_of_symbols() returns EINVAL (22) and the 
range check can incorrectly accept out-of-range values (<22), undermining the 
intended fix. Add an explicit schema/type check before using the symbol count.



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