Fix out-of-bounds read on invalid query message

When the parsing of a query failed, the message would treat the parameter
as a string as the printf format was `%*s` instead of `%.*s`.

The manpage of printf states the following about the precision specifier:

    ... or the maximum number of characters to be printed from a string
        for `s` and `S` conversions.

This means that the field length specifier is somewhat meaningless for
strings.
This commit is contained in:
Markus Mäkelä 2018-02-16 11:00:18 +02:00
parent 71c6f4db4e
commit bce5627ee3
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -3603,7 +3603,7 @@ static void log_invalid_data(GWBUF* query, const char* message)
length = (int)GWBUF_LENGTH(query) - MYSQL_HEADER_LEN - 1;
}
MXS_INFO("Parsing the query failed, %s: %*s", message, length, sql);
MXS_INFO("Parsing the query failed, %s: %.*s", message, length, sql);
}
}
}