-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[C] Fix negative block size validation in datafile reader #3623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -451,12 +451,24 @@ static int file_read_block_count(avro_file_reader_t r) | |
| "Cannot read file block count: "); | ||
| check_prefix(rval, enc->read_long(r->reader, &len), | ||
| "Cannot read file block size: "); | ||
| if (len < 0) { | ||
martin-g marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| avro_set_error("Invalid block size: %" PRId64, len); | ||
| return EINVAL; | ||
| } | ||
|
Comment on lines
+454
to
+457
|
||
|
|
||
| if (r->current_blockdata && len > r->current_blocklen) { | ||
| r->current_blockdata = (char *) avro_realloc(r->current_blockdata, r->current_blocklen, len); | ||
martin-g marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (!r->current_blockdata) { | ||
| avro_set_error("Cannot allocate block buffer"); | ||
| return ENOMEM; | ||
| } | ||
| r->current_blocklen = len; | ||
| } else if (!r->current_blockdata) { | ||
| r->current_blockdata = (char *) avro_malloc(len); | ||
| if (!r->current_blockdata && len > 0) { | ||
| avro_set_error("Cannot allocate block buffer"); | ||
| return ENOMEM; | ||
| } | ||
| r->current_blocklen = len; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.