mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-02-03 20:29:28 -05:00
- Cleanup unnecessary strdup calls for EDE strings.
This commit is contained in:
parent
15dc8e8a3f
commit
63a6b7b255
6 changed files with 18 additions and 31 deletions
|
|
@ -1,3 +1,6 @@
|
|||
29 April 2024: Yorgos
|
||||
- Cleanup unnecessary strdup calls for EDE strings.
|
||||
|
||||
26 April 2024: Wouter
|
||||
- Fix cachedb with serve-expired-client-timeout disabled. The edns
|
||||
subnet module deletes global cache and cachedb cache when it
|
||||
|
|
|
|||
|
|
@ -4045,17 +4045,9 @@ processFinished(struct module_qstate* qstate, struct iter_qstate* iq,
|
|||
!qstate->env->cfg->val_log_squelch) {
|
||||
char* err_str = errinf_to_str_misc(qstate);
|
||||
if(err_str) {
|
||||
size_t err_str_len = strlen(err_str);
|
||||
verbose(VERB_ALGO, "iterator EDE: %s", err_str);
|
||||
/* allocate space and store the error
|
||||
* string */
|
||||
iq->response->rep->reason_bogus_str = regional_alloc(
|
||||
qstate->region,
|
||||
sizeof(char) * (err_str_len+1));
|
||||
memcpy(iq->response->rep->reason_bogus_str,
|
||||
err_str, err_str_len+1);
|
||||
iq->response->rep->reason_bogus_str = err_str;
|
||||
}
|
||||
free(err_str);
|
||||
}
|
||||
|
||||
/* we have finished processing this query */
|
||||
|
|
|
|||
|
|
@ -1202,7 +1202,7 @@ mesh_do_callback(struct mesh_state* m, int rcode, struct reply_info* rep,
|
|||
rcode = LDNS_RCODE_SERVFAIL;
|
||||
if(!rcode && rep && (rep->security == sec_status_bogus ||
|
||||
rep->security == sec_status_secure_sentinel_fail)) {
|
||||
if(!(reason = errinf_to_str_bogus(&m->s)))
|
||||
if(!(reason = errinf_to_str_bogus(&m->s, NULL)))
|
||||
rcode = LDNS_RCODE_SERVFAIL;
|
||||
}
|
||||
/* send the reply */
|
||||
|
|
@ -1487,9 +1487,7 @@ void mesh_query_done(struct mesh_state* mstate)
|
|||
&& mstate->s.env->cfg->log_servfail
|
||||
&& !mstate->s.env->cfg->val_log_squelch) {
|
||||
char* err = errinf_to_str_servfail(&mstate->s);
|
||||
if(err)
|
||||
log_err("%s", err);
|
||||
free(err);
|
||||
if(err) { log_err("%s", err); }
|
||||
}
|
||||
}
|
||||
for(r = mstate->reply_list; r; r = r->next) {
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ void errinf_origin(struct module_qstate* qstate, struct sock_list *origin)
|
|||
}
|
||||
}
|
||||
|
||||
char* errinf_to_str_bogus(struct module_qstate* qstate)
|
||||
char* errinf_to_str_bogus(struct module_qstate* qstate, struct regional* region)
|
||||
{
|
||||
char buf[20480];
|
||||
char* p = buf;
|
||||
|
|
@ -148,7 +148,10 @@ char* errinf_to_str_bogus(struct module_qstate* qstate)
|
|||
snprintf(p, left, " %s", s->str);
|
||||
left -= strlen(p); p += strlen(p);
|
||||
}
|
||||
p = strdup(buf);
|
||||
if(region)
|
||||
p = regional_strdup(region, buf);
|
||||
else
|
||||
p = strdup(buf);
|
||||
if(!p)
|
||||
log_err("malloc failure in errinf_to_str");
|
||||
return p;
|
||||
|
|
@ -188,7 +191,7 @@ char* errinf_to_str_servfail(struct module_qstate* qstate)
|
|||
snprintf(p, left, " %s", s->str);
|
||||
left -= strlen(p); p += strlen(p);
|
||||
}
|
||||
p = strdup(buf);
|
||||
p = regional_strdup(qstate->region, buf);
|
||||
if(!p)
|
||||
log_err("malloc failure in errinf_to_str");
|
||||
return p;
|
||||
|
|
@ -206,7 +209,7 @@ char* errinf_to_str_misc(struct module_qstate* qstate)
|
|||
snprintf(p, left, "%s%s", (s==qstate->errinf?"":" "), s->str);
|
||||
left -= strlen(p); p += strlen(p);
|
||||
}
|
||||
p = strdup(buf);
|
||||
p = regional_strdup(qstate->region, buf);
|
||||
if(!p)
|
||||
log_err("malloc failure in errinf_to_str");
|
||||
return p;
|
||||
|
|
|
|||
|
|
@ -832,9 +832,9 @@ void errinf_dname(struct module_qstate* qstate, const char* str,
|
|||
* Create error info in string. For validation failures.
|
||||
* @param qstate: query state.
|
||||
* @return string or NULL on malloc failure (already logged).
|
||||
* This string is malloced and has to be freed by caller.
|
||||
* This string is malloced if region is NULL and has to be freed by caller.
|
||||
*/
|
||||
char* errinf_to_str_bogus(struct module_qstate* qstate);
|
||||
char* errinf_to_str_bogus(struct module_qstate* qstate, struct regional* region);
|
||||
|
||||
/**
|
||||
* Check the sldns_ede_code of the qstate->errinf.
|
||||
|
|
@ -847,7 +847,6 @@ sldns_ede_code errinf_to_reason_bogus(struct module_qstate* qstate);
|
|||
* Create error info in string. For other servfails.
|
||||
* @param qstate: query state.
|
||||
* @return string or NULL on malloc failure (already logged).
|
||||
* This string is malloced and has to be freed by caller.
|
||||
*/
|
||||
char* errinf_to_str_servfail(struct module_qstate* qstate);
|
||||
|
||||
|
|
@ -855,7 +854,6 @@ char* errinf_to_str_servfail(struct module_qstate* qstate);
|
|||
* Create error info in string. For misc failures that are not servfail.
|
||||
* @param qstate: query state.
|
||||
* @return string or NULL on malloc failure (already logged).
|
||||
* This string is malloced and has to be freed by caller.
|
||||
*/
|
||||
char* errinf_to_str_misc(struct module_qstate* qstate);
|
||||
|
||||
|
|
|
|||
|
|
@ -2453,19 +2453,12 @@ processFinished(struct module_qstate* qstate, struct val_qstate* vq,
|
|||
log_query_info(NO_VERBOSE, "validation failure",
|
||||
&qstate->qinfo);
|
||||
else {
|
||||
char* err_str = errinf_to_str_bogus(qstate);
|
||||
char* err_str = errinf_to_str_bogus(qstate,
|
||||
qstate->region);
|
||||
if(err_str) {
|
||||
size_t err_str_len = strlen(err_str);
|
||||
log_info("%s", err_str);
|
||||
/* allocate space and store the error
|
||||
* string */
|
||||
vq->orig_msg->rep->reason_bogus_str = regional_alloc(
|
||||
qstate->region,
|
||||
sizeof(char) * (err_str_len+1));
|
||||
memcpy(vq->orig_msg->rep->reason_bogus_str,
|
||||
err_str, err_str_len+1);
|
||||
vq->orig_msg->rep->reason_bogus_str = err_str;
|
||||
}
|
||||
free(err_str);
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue