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:
@ -142,6 +142,8 @@ char* maxavro_read_string(MAXAVRO_FILE* file, size_t* size)
|
|||||||
uint64_t len;
|
uint64_t len;
|
||||||
|
|
||||||
if (maxavro_read_integer(file, &len))
|
if (maxavro_read_integer(file, &len))
|
||||||
|
{
|
||||||
|
if (file->buffer_ptr + len < file->buffer_end)
|
||||||
{
|
{
|
||||||
key = MXS_MALLOC(len + 1);
|
key = MXS_MALLOC(len + 1);
|
||||||
if (key)
|
if (key)
|
||||||
@ -156,6 +158,11 @@ char* maxavro_read_string(MAXAVRO_FILE* file, size_t* size)
|
|||||||
file->last_error = MAXAVRO_ERR_MEMORY;
|
file->last_error = MAXAVRO_ERR_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
file->last_error = MAXAVRO_ERR_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user