Skip to content
Snippets Groups Projects
Commit 894165c9 authored by Marek Vavruša's avatar Marek Vavruša
Browse files

lib: fixed possible null pointers passed to nonnull arguments

parent 97449691
No related branches found
No related tags found
1 merge request!432ci: add -Werror to CFLAGS, added clang build target
Pipeline #
......@@ -222,7 +222,7 @@ static int covers_name(int *flags, const knot_rrset_t *nsec3, const knot_dname_t
uint8_t *next_hash = NULL;
knot_nsec3_next_hashed(&nsec3->rrs, 0, &next_hash, &next_size);
if ((owner_hash.size == next_size) && (name_hash.size == next_size)) {
if ((next_size > 0) && (owner_hash.size == next_size) && (name_hash.size == next_size)) {
/* All hash lengths must be same. */
const uint8_t *ownrd = owner_hash.data;
const uint8_t *nextd = next_hash;
......
......@@ -152,7 +152,7 @@ KR_EXPORT void * lru_get_impl(struct lru *lru, const char *key, uint key_len,
if (g->hashes[i] == khash_top) {
it = g->items[i];
if (likely(it && it->key_len == key_len
&& memcmp(it->data, key, key_len) == 0))
&& (key_len == 0 || memcmp(it->data, key, key_len) == 0)))
goto found; // to reduce huge nesting depth
}
}
......@@ -200,7 +200,9 @@ KR_EXPORT void * lru_get_impl(struct lru *lru, const char *key, uint key_len,
}
it->key_len = key_len;
it->val_len = val_len;
memcpy(it->data, key, key_len);
if (key_len > 0) {
memcpy(it->data, key, key_len);
}
memset(item_val(it), 0, val_len); // clear the value
found: // key and hash OK on g->items[i]; now update stamps
assert(i < LRU_ASSOC);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment