MXS-2507: Check stored integer size
If the avro block is smaller than the size of the stored data, the file was created with a block size that was too small. Even the reference Avro implementation can't read the file in this case.
This commit is contained in:
parent
387bf0ccc2
commit
3721d6abf2
@ -143,13 +143,20 @@ char* maxavro_read_string(MAXAVRO_FILE* file, size_t* size)
|
||||
|
||||
if (maxavro_read_integer(file, &len))
|
||||
{
|
||||
key = MXS_MALLOC(len + 1);
|
||||
if (key)
|
||||
if (file->buffer_ptr + len < file->buffer_end)
|
||||
{
|
||||
memcpy(key, file->buffer_ptr, len);
|
||||
key[len] = '\0';
|
||||
file->buffer_ptr += len;
|
||||
*size = len;
|
||||
key = MXS_MALLOC(len + 1);
|
||||
if (key)
|
||||
{
|
||||
memcpy(key, file->buffer_ptr, len);
|
||||
key[len] = '\0';
|
||||
file->buffer_ptr += len;
|
||||
*size = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
file->last_error = MAXAVRO_ERR_MEMORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user