From: George Thessalonikefs Date: Fri, 28 Jul 2023 10:50:36 +0000 (+0200) Subject: Address review comments for #759: X-Git-Tag: release-1.18.0rc1~24^2^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=50ea4a1072a51773878d5c2a2dc73d4e639b476d;p=thirdparty%2Funbound.git Address review comments for #759: - Decrease allocations for "" EDE strings when loading the cachedump. - Check for existence of EDE code before attaching. --- diff --git a/daemon/cachedump.c b/daemon/cachedump.c index a90f04f2a..61ee1d291 100644 --- a/daemon/cachedump.c +++ b/daemon/cachedump.c @@ -651,14 +651,15 @@ load_msg(RES* ssl, sldns_buffer* buf, struct worker* worker) } /* read remainder of line */ - if(sscanf(s, " %u %u " ARG_LL "d %u %u %u %u %d%n", &flags, &qdcount, &ttl, + /* note the last space before any possible EDE text */ + if(sscanf(s, " %u %u " ARG_LL "d %u %u %u %u %d %n", &flags, &qdcount, &ttl, &security, &an, &ns, &ar, &ede, &consumed) != 8) { log_warn("error cannot parse numbers: %s", s); return 0; } /* there may be EDE text after the numbers */ if(consumed > 0 && (size_t)consumed < strlen(s)) - ede_str = s + consumed + 1 /* space */; + ede_str = s + consumed; memset(&rep, 0, sizeof(rep)); rep.flags = (uint16_t)flags; rep.qdcount = (uint16_t)qdcount; diff --git a/daemon/worker.c b/daemon/worker.c index 529b22ae4..1b988ed36 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -508,7 +508,8 @@ answer_norec_from_cache(struct worker* worker, struct query_info* qinfo, worker->env.now_tv)) return 0; /* Attach the cached EDE (RFC8914) */ - if(worker->env.cfg->ede) { + if(worker->env.cfg->ede && + msg->rep->reason_bogus != LDNS_EDE_NONE) { edns_opt_list_append_ede(&edns->opt_list_out, worker->scratchpad, msg->rep->reason_bogus, msg->rep->reason_bogus_str); @@ -694,7 +695,7 @@ answer_from_cache(struct worker* worker, struct query_info* qinfo, worker->env.now_tv)) goto bail_out; /* Attach the cached EDE (RFC8914) */ - if(worker->env.cfg->ede) { + if(worker->env.cfg->ede && rep->reason_bogus != LDNS_EDE_NONE) { edns_opt_list_append_ede(&edns->opt_list_out, worker->scratchpad, rep->reason_bogus, rep->reason_bogus_str); diff --git a/services/mesh.c b/services/mesh.c index 683c76407..5fa467d18 100644 --- a/services/mesh.c +++ b/services/mesh.c @@ -1253,7 +1253,7 @@ mesh_find_and_attach_ede_and_reason(struct mesh_state* m, * but a compelling reason to do otherwise is just as valid * NEW note: * The compelling reason is that with caching support, the value - * in the * reply_info is cached. + * in the reply_info is cached. * The reason members of the reply_info struct should be * updated as they are already cached. No reason to * try and find the EDE information in errinf anymore.