Commit b0d1a920 authored by Karel Slaný's avatar Karel Slaný Committed by Ondřej Surý

Added check for cookie OPT size before storing into LRU cache.

parent daae8b18
......@@ -54,14 +54,18 @@ int kr_cookie_lru_set(kr_cookie_lru_t *cache, const struct sockaddr *sa,
return kr_error(EINVAL);
}
uint16_t opt_size = KNOT_EDNS_OPTION_HDRLEN +
knot_edns_opt_get_length(opt);
if (opt_size > KR_COOKIE_OPT_MAX_LEN) {
return kr_error(EINVAL);
}
struct cookie_opt_data *cached = lru_set(cache, addr, addr_len);
if (!cached) {
return kr_error(ENOMEM);
}
uint16_t opt_size = KNOT_EDNS_OPTION_HDRLEN +
knot_edns_opt_get_length(opt);
memcpy(cached->opt_data, opt, opt_size);
return kr_ok();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment