[
https://issues.apache.org/jira/browse/AVRO-1528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14061800#comment-14061800
]
Jeno I. Hajdu commented on AVRO-1528:
-------------------------------------
OK, so the scenarios is that we have versioned data (schemas for the various
versions auto generated) where we would want to use enums and would read the
data using a manually assembled reader schema. We would use the reader schema
to convert enums to string instead of the writer schema to avoid leaking
specifics of a given version. Now if the specific writer schema has additional
items for an enum compared to what we have in our reader schema we will
eventually try to look up such unknown indices.
Theoretically we could work around this in other ways, but Avro-C is also
lacking in that regard, I am OK, if we choose to fix that. For example I
haven't found any specific schema function or straightforward approach which
could tell me how many items an enum has. Otherwise I could do the bound
checking myself before the lookup.
This also applies to the writer side, avro_value_set_enum() does not do any
bound checking based on the schema, which is understandable due to performance,
but there's no way for manual bound checking prior the writing either.
So, as an alternative proposal what do you think of adding
avro_schema_enum_get_item_count(const avro_schema_t), which returns the
num_entries of the symbols st_table? Then all the enum bound checkings can be
left to the users if they opt to want that.
If you are OK with this I can attach a new patch with that one.
> avro_schema_enum_get returns invalid pointer for unknown indices
> ----------------------------------------------------------------
>
> Key: AVRO-1528
> URL: https://issues.apache.org/jira/browse/AVRO-1528
> Project: Avro
> Issue Type: Bug
> Components: c
> Affects Versions: 1.7.6
> Reporter: Jeno I. Hajdu
> Priority: Trivial
> Attachments: AVRO-1528.patch
>
>
> When avro_schema_enum_get() is called with invalid indices it returns an
> invalid pointer instead of NULL, this leads to segfaults. Similar problem is
> already handled in avro_schema_enum_get_by_name() when converting the other
> way round, avro_schema_enum_get() could handle it likewise.
--
This message was sent by Atlassian JIRA
(v6.2#6252)