diff options
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sql/table.cc b/sql/table.cc index e4501870a2b..ccc336962b6 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -4298,6 +4298,21 @@ bool check_table_name(const char *name, size_t length, bool check_for_path_chars if (check_for_path_chars && (*name == '/' || *name == '\\' || *name == '~' || *name == FN_EXTCHAR)) return 1; + /* + We don't allow zero byte in table/schema names: + - Some code still uses NULL-terminated strings. + Zero bytes will confuse this code. + - There is a little practical use of zero bytes in names anyway. + Note, if the string passed as "name" comes here + from the parser as an identifier, it does not contain zero bytes, + as the parser rejects zero bytes in identifiers. + But "name" can also come here from queries like this: + SELECT * FROM I_S.TABLES WHERE TABLE_NAME='str'; + In this case "name" is a general string expression + and it can have any arbitrary bytes, including zero bytes. + */ + if (*name == 0x00) + return 1; name++; name_length++; } |