if (sz <= 0)
return -ENOSPC;
+ if (r >= DNS_LABEL_MAX)
+ return -EINVAL;
+
if (*n == '\\') {
/* Escaped character */
assert(p);
assert(ret);
+ if (l > DNS_LABEL_MAX)
+ return -EINVAL;
+
s = malloc(l * 4 + 1);
if (!s)
return -ENOMEM;
n += r;
}
+ if (n > DNS_NAME_MAX)
+ return -EINVAL;
+
if (!GREEDY_REALLOC(ret, allocated, n + 1))
return -ENOMEM;
unsigned long dns_name_hash_func(const void *s, const uint8_t hash_key[HASH_KEY_SIZE]) {
const char *p = s;
- unsigned long ul = 0;
+ unsigned long ul = hash_key[0];
int r;
assert(p);
label[r] = 0;
ascii_strlower(label);
- ul = hash_key[0] * ul + ul + string_hash_func(label, hash_key);
+ ul = ul * hash_key[1] + ul + string_hash_func(label, hash_key);
}
return ul;