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:
Markus Mäkelä
2019-05-27 15:07:35 +03:00
parent 387bf0ccc2
commit 3721d6abf2

View File

@ -142,6 +142,8 @@ char* maxavro_read_string(MAXAVRO_FILE* file, size_t* size)
uint64_t len;
if (maxavro_read_integer(file, &len))
{
if (file->buffer_ptr + len < file->buffer_end)
{
key = MXS_MALLOC(len + 1);
if (key)
@ -156,6 +158,11 @@ char* maxavro_read_string(MAXAVRO_FILE* file, size_t* size)
file->last_error = MAXAVRO_ERR_MEMORY;
}
}
else
{
file->last_error = MAXAVRO_ERR_MEMORY;
}
}
return key;
}