MXS-1216: Fix processing of long fixed strings
The fixed length string processing assumed that the string lengths were contained in the first byte. This is not true for large fixed length strings that take more than 255 bytes to store. This consists of multi-byte character strings that can take up to 1024 bytes to store.
This commit is contained in:
@ -550,12 +550,31 @@ uint8_t* process_row_event_data(TABLE_MAP *map, TABLE_CREATE *create, avro_value
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint8_t bytes = *ptr;
|
/**
|
||||||
|
* The first byte in the metadata stores the real type of
|
||||||
|
* the string (ENUM and SET types are also stored as fixed
|
||||||
|
* length strings).
|
||||||
|
*
|
||||||
|
* The first two bits of the second byte contain the XOR'ed
|
||||||
|
* field length but as that information is not relevant for
|
||||||
|
* us, we just use this information to know whether to read
|
||||||
|
* one or two bytes for string length.
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint8_t bytes = *ptr++;
|
||||||
|
int len = metadata[metadata_offset] +
|
||||||
|
(((metadata[metadata_offset + 1] >> 4) & 0x3) ^ 0x3);
|
||||||
|
|
||||||
|
if (len <= 255)
|
||||||
|
{
|
||||||
|
bytes += *ptr++ << 8;
|
||||||
|
}
|
||||||
|
|
||||||
char str[bytes + 1];
|
char str[bytes + 1];
|
||||||
memcpy(str, ptr + 1, bytes);
|
memcpy(str, ptr, bytes);
|
||||||
str[bytes] = '\0';
|
str[bytes] = '\0';
|
||||||
avro_value_set_string(&field, str);
|
avro_value_set_string(&field, str);
|
||||||
ptr += bytes + 1;
|
ptr += bytes;
|
||||||
ss_dassert(ptr < end);
|
ss_dassert(ptr < end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user