Fix avrorouter type and name handling
The type and name parsing functions could move outside of allocated memory as they didn't check for the terminating null character. Also fixed the printf format string used when the list of used tables is being created. Fixed CDC testing connector to abort on error and added some extra output to the cdc_datatypes test.
This commit is contained in:
@ -124,6 +124,8 @@ char* json_new_schema_from_table(TABLE_MAP *map)
|
||||
|
||||
for (uint64_t i = 0; i < map->columns; i++)
|
||||
{
|
||||
ss_info_dassert(create->column_names[i] && *create->column_names[i],
|
||||
"Column name should not be empty or NULL");
|
||||
json_array_append(array, json_pack_ex(&err, 0, "{s:s, s:s, s:s, s:i}",
|
||||
"name", create->column_names[i],
|
||||
"type", column_type_to_avro_type(map->column_types[i]),
|
||||
@ -543,6 +545,7 @@ static const char *extract_field_name(const char* ptr, char* dest, size_t size)
|
||||
dest[bytes] = '\0';
|
||||
|
||||
make_valid_avro_identifier(dest);
|
||||
ss_dassert(strlen(dest) > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -555,7 +558,7 @@ static const char *extract_field_name(const char* ptr, char* dest, size_t size)
|
||||
int extract_type_length(const char* ptr, char *dest)
|
||||
{
|
||||
/** Skip any leading whitespace */
|
||||
while (isspace(*ptr) || *ptr == '`')
|
||||
while (*ptr && (isspace(*ptr) || *ptr == '`'))
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
@ -565,7 +568,7 @@ int extract_type_length(const char* ptr, char *dest)
|
||||
|
||||
/** Skip characters until we either hit a whitespace character or the start
|
||||
* of the length definition. */
|
||||
while (!isspace(*ptr) && *ptr != '(')
|
||||
while (*ptr && !isspace(*ptr) && *ptr != '(')
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
@ -576,7 +579,7 @@ int extract_type_length(const char* ptr, char *dest)
|
||||
dest[typelen] = '\0';
|
||||
|
||||
/** Skip whitespace */
|
||||
while (isspace(*ptr))
|
||||
while (*ptr && isspace(*ptr))
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
@ -641,6 +644,7 @@ static int process_column_definition(const char *nameptr, char*** dest, char***
|
||||
lengths[i] = len;
|
||||
types[i] = MXS_STRDUP_A(type);
|
||||
names[i] = MXS_STRDUP_A(colname);
|
||||
ss_info_dassert(*names[i] && *types[i], "`name` and `type` must not be empty");
|
||||
i++;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user