mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-19 03:20:41 +01:00
lookup tables: fix undefined behaviour
bsearch is not permitted to be called with NULL ptr for array. Detectedb by LLVM UBSan. see also https://github.com/rsyslog/rsyslog/issues/2295
This commit is contained in:
parent
2d1aa30367
commit
4f13c27d5a
@ -301,8 +301,13 @@ static es_str_t*
|
||||
lookupKey_str(lookup_t *pThis, lookup_key_t key) {
|
||||
lookup_string_tab_entry_t *entry;
|
||||
const char *r;
|
||||
entry = bsearch(key.k_str, pThis->table.str->entries, pThis->nmemb, sizeof(lookup_string_tab_entry_t),
|
||||
bs_arrcmp_strtab);
|
||||
if(pThis->nmemb == 0) {
|
||||
entry = NULL;
|
||||
} else {
|
||||
assert(pThis->table.str->entries);
|
||||
entry = bsearch(key.k_str, pThis->table.str->entries, pThis->nmemb,
|
||||
sizeof(lookup_string_tab_entry_t), bs_arrcmp_strtab);
|
||||
}
|
||||
if(entry == NULL) {
|
||||
r = defaultVal(pThis);
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user