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:
@ -143,13 +143,20 @@ char* maxavro_read_string(MAXAVRO_FILE* file, size_t* size)
|
|||||||
|
|
||||||
if (maxavro_read_integer(file, &len))
|
if (maxavro_read_integer(file, &len))
|
||||||
{
|
{
|
||||||
key = MXS_MALLOC(len + 1);
|
if (file->buffer_ptr + len < file->buffer_end)
|
||||||
if (key)
|
|
||||||
{
|
{
|
||||||
memcpy(key, file->buffer_ptr, len);
|
key = MXS_MALLOC(len + 1);
|
||||||
key[len] = '\0';
|
if (key)
|
||||||
file->buffer_ptr += len;
|
{
|
||||||
*size = len;
|
memcpy(key, file->buffer_ptr, len);
|
||||||
|
key[len] = '\0';
|
||||||
|
file->buffer_ptr += len;
|
||||||
|
*size = len;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
file->last_error = MAXAVRO_ERR_MEMORY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user