diff --git a/lang/c/src/schema.c b/lang/c/src/schema.c index a4d8e9f898a..9e91aca8da1 100644 --- a/lang/c/src/schema.c +++ b/lang/c/src/schema.c @@ -325,6 +325,11 @@ avro_schema_t avro_schema_fixed_ns(const char *name, const char *space, return NULL; } + if (size < 0) { + avro_set_error("Invalid size for fixed schema"); + return NULL; + } + struct avro_fixed_schema_t *fixed = (struct avro_fixed_schema_t *) avro_new(struct avro_fixed_schema_t); if (!fixed) { diff --git a/lang/c/tests/schema_tests/fail/fixed_negative_size b/lang/c/tests/schema_tests/fail/fixed_negative_size new file mode 100644 index 00000000000..6ff5cf8eca4 --- /dev/null +++ b/lang/c/tests/schema_tests/fail/fixed_negative_size @@ -0,0 +1,3 @@ +{"type": "fixed", + "name": "F", + "size": -1}