assert(rr->type == KNOT_RRTYPE_NSEC3);
const knot_rdata_t *np_data = knot_rdata_data(rr->rrs.data);
+ const int rdlen = knot_rdata_rdlen(rr->rrs.data);
+ if (rdlen <= 4) return kr_error(EILSEQ); /*< data from outside; less trust */
const int np_dlen = nsec_p_rdlen(np_data);
+ if (np_dlen > rdlen) return kr_error(EILSEQ);
key = key_NSEC3(k, encloser, nsec_p_mkHash(np_data));
if (npp && !*npp) {
*npp = mm_alloc(&qry->request->pool, np_dlen);
ssize_t written = stash_rrset(cache, qry, rr, rr_sigs, qry->timestamp.tv_sec,
entry->rank, nsec_pmap, has_optout);
if (written < 0) {
+ kr_log_error("[%5hu][cach] stash failed, ret = %d\n", qry->id, ret);
return (int) written;
}
static inline int nsec_p_rdlen(const uint8_t *rdata)
{
- //TODO: the zero case? // FIXME security: overflow potential
+ //TODO: the zero case?
return rdata ? 5 + rdata[4] : 0; /* rfc5155 4.2 and 3.2. */
}
static const int NSEC_P_MAXLEN = sizeof(uint32_t) + 5 + 255; // TODO: remove??