mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
- Fix warnings reported by the gcc analyzer.
This commit is contained in:
parent
7694998ea9
commit
d3b2bc501d
8 changed files with 53 additions and 9 deletions
|
|
@ -1012,6 +1012,7 @@ void dtio_tap_callback(int fd, short ATTR_UNUSED(bits), void* arg)
|
||||||
if(verbosity) log_info("bidirectional stream");
|
if(verbosity) log_info("bidirectional stream");
|
||||||
if(!reply_with_accept(data)) {
|
if(!reply_with_accept(data)) {
|
||||||
tap_data_free(data);
|
tap_data_free(data);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else if(data->len >= 4 && sldns_read_uint32(data->frame) ==
|
} else if(data->len >= 4 && sldns_read_uint32(data->frame) ==
|
||||||
FSTRM_CONTROL_FRAME_STOP && data->is_bidirectional) {
|
FSTRM_CONTROL_FRAME_STOP && data->is_bidirectional) {
|
||||||
|
|
@ -1166,8 +1167,12 @@ int sig_quit = 0;
|
||||||
/** signal handler for user quit */
|
/** signal handler for user quit */
|
||||||
static RETSIGTYPE main_sigh(int sig)
|
static RETSIGTYPE main_sigh(int sig)
|
||||||
{
|
{
|
||||||
if(!sig_quit)
|
if(!sig_quit) {
|
||||||
fprintf(stderr, "exit on signal %d\n", sig);
|
char str[] = "exit on signal \n";
|
||||||
|
str[15] = '0' + (sig/10)%10;
|
||||||
|
str[16] = '0' + sig%10;
|
||||||
|
write(STDERR_FILENO, str, strlen(str));
|
||||||
|
}
|
||||||
if(sig_base) {
|
if(sig_base) {
|
||||||
ub_event_base_loopexit(sig_base);
|
ub_event_base_loopexit(sig_base);
|
||||||
sig_base = NULL;
|
sig_base = NULL;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
23 June 2021: Wouter
|
23 June 2021: Wouter
|
||||||
- Fix #503: DNS over HTTPS response truncated.
|
- Fix #503: DNS over HTTPS response truncated.
|
||||||
|
- Fix warnings reported by the gcc analyzer.
|
||||||
|
|
||||||
21 June 2021: George
|
21 June 2021: George
|
||||||
- Fix #495: Documentation or implementation of "verbosity" option.
|
- Fix #495: Documentation or implementation of "verbosity" option.
|
||||||
|
|
|
||||||
|
|
@ -456,8 +456,15 @@ fill_res(struct ub_result* res, struct ub_packed_rrset_key* answer,
|
||||||
if(rep->rrset_count != 0)
|
if(rep->rrset_count != 0)
|
||||||
res->ttl = (int)rep->ttl;
|
res->ttl = (int)rep->ttl;
|
||||||
res->data = (char**)calloc(1, sizeof(char*));
|
res->data = (char**)calloc(1, sizeof(char*));
|
||||||
|
if(!res->data)
|
||||||
|
return 0; /* out of memory */
|
||||||
res->len = (int*)calloc(1, sizeof(int));
|
res->len = (int*)calloc(1, sizeof(int));
|
||||||
return (res->data && res->len);
|
if(!res->len) {
|
||||||
|
free(res->data);
|
||||||
|
res->data = NULL;
|
||||||
|
return 0; /* out of memory */
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
data = (struct packed_rrset_data*)answer->entry.data;
|
data = (struct packed_rrset_data*)answer->entry.data;
|
||||||
if(query_dname_compare(rq->qname, answer->rk.dname) != 0) {
|
if(query_dname_compare(rq->qname, answer->rk.dname) != 0) {
|
||||||
|
|
@ -465,15 +472,30 @@ fill_res(struct ub_result* res, struct ub_packed_rrset_key* answer,
|
||||||
return 0; /* out of memory */
|
return 0; /* out of memory */
|
||||||
} else res->canonname = NULL;
|
} else res->canonname = NULL;
|
||||||
res->data = (char**)calloc(data->count+1, sizeof(char*));
|
res->data = (char**)calloc(data->count+1, sizeof(char*));
|
||||||
res->len = (int*)calloc(data->count+1, sizeof(int));
|
if(!res->data)
|
||||||
if(!res->data || !res->len)
|
|
||||||
return 0; /* out of memory */
|
return 0; /* out of memory */
|
||||||
|
res->len = (int*)calloc(data->count+1, sizeof(int));
|
||||||
|
if(!res->len) {
|
||||||
|
free(res->data);
|
||||||
|
res->data = NULL;
|
||||||
|
return 0; /* out of memory */
|
||||||
|
}
|
||||||
for(i=0; i<data->count; i++) {
|
for(i=0; i<data->count; i++) {
|
||||||
/* remove rdlength from rdata */
|
/* remove rdlength from rdata */
|
||||||
res->len[i] = (int)(data->rr_len[i] - 2);
|
res->len[i] = (int)(data->rr_len[i] - 2);
|
||||||
res->data[i] = memdup(data->rr_data[i]+2, (size_t)res->len[i]);
|
res->data[i] = memdup(data->rr_data[i]+2, (size_t)res->len[i]);
|
||||||
if(!res->data[i])
|
if(!res->data[i]) {
|
||||||
|
size_t j;
|
||||||
|
for(j=0; j<i; j++) {
|
||||||
|
free(res->data[j]);
|
||||||
|
res->data[j] = NULL;
|
||||||
|
}
|
||||||
|
free(res->data);
|
||||||
|
res->data = NULL;
|
||||||
|
free(res->len);
|
||||||
|
res->len = NULL;
|
||||||
return 0; /* out of memory */
|
return 0; /* out of memory */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* ttl for positive answers, from CNAME and answer RRs */
|
/* ttl for positive answers, from CNAME and answer RRs */
|
||||||
if(data->count != 0) {
|
if(data->count != 0) {
|
||||||
|
|
|
||||||
|
|
@ -936,6 +936,8 @@ int _ub_resolve_async(struct ub_ctx* ctx, char* name, int rrtype, int rrclass, v
|
||||||
int r;
|
int r;
|
||||||
struct cb_data* id;
|
struct cb_data* id;
|
||||||
id = (struct cb_data*) malloc(sizeof(struct cb_data));
|
id = (struct cb_data*) malloc(sizeof(struct cb_data));
|
||||||
|
if(!id)
|
||||||
|
return -2; /* UB_NOMEM */
|
||||||
id->data = mydata;
|
id->data = mydata;
|
||||||
id->func = pyfunc;
|
id->func = pyfunc;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,10 @@ static volatile int do_quit = 0;
|
||||||
/** signal handler for user quit */
|
/** signal handler for user quit */
|
||||||
static RETSIGTYPE delayer_sigh(int sig)
|
static RETSIGTYPE delayer_sigh(int sig)
|
||||||
{
|
{
|
||||||
printf("exit on signal %d\n", sig);
|
char str[] = "exit on signal \n";
|
||||||
|
str[15] = '0' + (sig/10)%10;
|
||||||
|
str[16] = '0' + sig%10;
|
||||||
|
write(STDOUT_FILENO, str, strlen(str));
|
||||||
do_quit = 1;
|
do_quit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -423,6 +423,7 @@ http2_session_create()
|
||||||
|
|
||||||
if(nghttp2_session_callbacks_new(&callbacks) == NGHTTP2_ERR_NOMEM) {
|
if(nghttp2_session_callbacks_new(&callbacks) == NGHTTP2_ERR_NOMEM) {
|
||||||
log_err("failed to initialize nghttp2 callback");
|
log_err("failed to initialize nghttp2 callback");
|
||||||
|
free(h2_session);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
nghttp2_session_callbacks_set_recv_callback(callbacks, http2_recv_cb);
|
nghttp2_session_callbacks_set_recv_callback(callbacks, http2_recv_cb);
|
||||||
|
|
|
||||||
|
|
@ -451,6 +451,8 @@ fake_front_query(struct replay_runtime* runtime, struct replay_moment *todo)
|
||||||
struct comm_reply repinfo;
|
struct comm_reply repinfo;
|
||||||
memset(&repinfo, 0, sizeof(repinfo));
|
memset(&repinfo, 0, sizeof(repinfo));
|
||||||
repinfo.c = (struct comm_point*)calloc(1, sizeof(struct comm_point));
|
repinfo.c = (struct comm_point*)calloc(1, sizeof(struct comm_point));
|
||||||
|
if(!repinfo.c)
|
||||||
|
fatal_exit("out of memory in fake_front_query");
|
||||||
repinfo.addrlen = (socklen_t)sizeof(struct sockaddr_in);
|
repinfo.addrlen = (socklen_t)sizeof(struct sockaddr_in);
|
||||||
if(todo->addrlen != 0) {
|
if(todo->addrlen != 0) {
|
||||||
repinfo.addrlen = todo->addrlen;
|
repinfo.addrlen = todo->addrlen;
|
||||||
|
|
@ -909,6 +911,8 @@ comm_base_create(int ATTR_UNUSED(sigs))
|
||||||
/* we return the runtime structure instead. */
|
/* we return the runtime structure instead. */
|
||||||
struct replay_runtime* runtime = (struct replay_runtime*)
|
struct replay_runtime* runtime = (struct replay_runtime*)
|
||||||
calloc(1, sizeof(struct replay_runtime));
|
calloc(1, sizeof(struct replay_runtime));
|
||||||
|
if(!runtime)
|
||||||
|
fatal_exit("out of memory in fake_event.c:comm_base_create");
|
||||||
runtime->scenario = saved_scenario;
|
runtime->scenario = saved_scenario;
|
||||||
runtime->vars = macro_store_create();
|
runtime->vars = macro_store_create();
|
||||||
if(!runtime->vars) fatal_exit("out of memory");
|
if(!runtime->vars) fatal_exit("out of memory");
|
||||||
|
|
@ -1534,6 +1538,8 @@ struct comm_timer* comm_timer_create(struct comm_base* base,
|
||||||
{
|
{
|
||||||
struct replay_runtime* runtime = (struct replay_runtime*)base;
|
struct replay_runtime* runtime = (struct replay_runtime*)base;
|
||||||
struct fake_timer* t = (struct fake_timer*)calloc(1, sizeof(*t));
|
struct fake_timer* t = (struct fake_timer*)calloc(1, sizeof(*t));
|
||||||
|
if(!t)
|
||||||
|
fatal_exit("out of memory in fake_event.c:comm_timer_create");
|
||||||
t->cb = cb;
|
t->cb = cb;
|
||||||
t->cb_arg = cb_arg;
|
t->cb_arg = cb_arg;
|
||||||
fptr_ok(fptr_whitelist_comm_timer(t->cb)); /* check in advance */
|
fptr_ok(fptr_whitelist_comm_timer(t->cb)); /* check in advance */
|
||||||
|
|
|
||||||
|
|
@ -397,11 +397,15 @@ send_em(const char* svr, int udp, int usessl, int noanswer, int onarrival,
|
||||||
/** SIGPIPE handler */
|
/** SIGPIPE handler */
|
||||||
static RETSIGTYPE sigh(int sig)
|
static RETSIGTYPE sigh(int sig)
|
||||||
{
|
{
|
||||||
|
char str[] = "Got unhandled signal \n";
|
||||||
if(sig == SIGPIPE) {
|
if(sig == SIGPIPE) {
|
||||||
printf("got SIGPIPE, remote connection gone\n");
|
char* strpipe = "got SIGPIPE, remote connection gone\n";
|
||||||
|
write(STDOUT_FILENO, strpipe, strlen(strpipe));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
printf("Got unhandled signal %d\n", sig);
|
str[21] = '0' + (sig/10)%10;
|
||||||
|
str[22] = '0' + sig%10;
|
||||||
|
write(STDOUT_FILENO, str, strlen(str));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#endif /* SIGPIPE */
|
#endif /* SIGPIPE */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue