Fix SIGSEGV on not existing attributes from ip_trie with access_to_key_from_attributes

Found with fuzzer [1]:

  [1]: https://clickhouse-test-reports.s3.yandex.net/21674/2e99dad56213413a72969d47650050b42cbcc073/fuzzer_asan/report.html#fail1
This commit is contained in:
Azat Khuzhin 2021-03-13 09:05:35 +03:00
parent b2a6a8feb8
commit 481d897cad
2 changed files with 5 additions and 0 deletions

View File

@ -241,6 +241,8 @@ const DictionaryAttribute & DictionaryStructure::getAttribute(const std::string
for (const auto & key_attribute : *key) for (const auto & key_attribute : *key)
if (key_attribute.name == attribute_name) if (key_attribute.name == attribute_name)
return key_attribute; return key_attribute;
throw Exception{"No such attribute '" + attribute_name + "'", ErrorCodes::BAD_ARGUMENTS};
} }
size_t attribute_index = it->second; size_t attribute_index = it->second;

View File

@ -41,6 +41,9 @@ SOURCE(CLICKHOUSE(host 'localhost' port 9000 user 'default' db 'database_for_dic
LAYOUT(IP_TRIE()) LAYOUT(IP_TRIE())
LIFETIME(MIN 10 MAX 100); LIFETIME(MIN 10 MAX 100);
-- fuzzer
SELECT '127.0.0.0/24' = dictGetString('database_for_dict.dict_ipv4_trie', 'prefixprefixprefixprefix', tuple(IPv4StringToNum('127.0.0.0127.0.0.0'))); -- { serverError 36 }
SELECT 0 == dictGetUInt32('database_for_dict.dict_ipv4_trie', 'asn', tuple(IPv4StringToNum('0.0.0.0'))); SELECT 0 == dictGetUInt32('database_for_dict.dict_ipv4_trie', 'asn', tuple(IPv4StringToNum('0.0.0.0')));
SELECT 1 == dictGetUInt32('database_for_dict.dict_ipv4_trie', 'asn', tuple(IPv4StringToNum('128.0.0.0'))); SELECT 1 == dictGetUInt32('database_for_dict.dict_ipv4_trie', 'asn', tuple(IPv4StringToNum('128.0.0.0')));
SELECT 2 == dictGetUInt32('database_for_dict.dict_ipv4_trie', 'asn', tuple(IPv4StringToNum('192.0.0.0'))); SELECT 2 == dictGetUInt32('database_for_dict.dict_ipv4_trie', 'asn', tuple(IPv4StringToNum('192.0.0.0')));