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
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -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
{