diff options
Diffstat (limited to 'libunbound')
| -rw-r--r-- | libunbound/context.c | 4 | ||||
| -rw-r--r-- | libunbound/libworker.c | 69 | ||||
| -rw-r--r-- | libunbound/python/libunbound.i | 8 | ||||
| -rw-r--r-- | libunbound/worker.h | 8 |
4 files changed, 39 insertions, 50 deletions
diff --git a/libunbound/context.c b/libunbound/context.c index cff2831a77cd..e589c6ae28d7 100644 --- a/libunbound/context.c +++ b/libunbound/context.c @@ -69,6 +69,7 @@ context_finalize(struct ub_ctx* ctx) } else { log_init(cfg->logfile, cfg->use_syslog, NULL); } + cfg_apply_local_port_policy(cfg, 65536); config_apply(cfg); if(!modstack_setup(&ctx->mods, cfg->module_conf, ctx->env)) return UB_INITFAIL; @@ -78,7 +79,8 @@ context_finalize(struct ub_ctx* ctx) return UB_NOMEM; if(!local_zones_apply_cfg(ctx->local_zones, cfg)) return UB_INITFAIL; - if(!auth_zones_apply_cfg(ctx->env->auth_zones, cfg, 1, &is_rpz)) + if(!auth_zones_apply_cfg(ctx->env->auth_zones, cfg, 1, &is_rpz, + ctx->env, &ctx->mods)) return UB_INITFAIL; if(!edns_strings_apply_cfg(ctx->env->edns_strings, cfg)) return UB_INITFAIL; diff --git a/libunbound/libworker.c b/libunbound/libworker.c index 7f46df386ab9..8a9ca9419480 100644 --- a/libunbound/libworker.c +++ b/libunbound/libworker.c @@ -241,7 +241,9 @@ libworker_setup(struct ub_ctx* ctx, int is_bg, struct ub_event_base* eb) ports, numports, cfg->unwanted_threshold, cfg->outgoing_tcp_mss, &libworker_alloc_cleanup, w, cfg->do_udp || cfg->udp_upstream_without_downstream, w->sslctx, - cfg->delay_close, cfg->tls_use_sni, NULL, cfg->udp_connect); + cfg->delay_close, cfg->tls_use_sni, NULL, cfg->udp_connect, + cfg->max_reuse_tcp_queries, cfg->tcp_reuse_timeout, + cfg->tcp_auth_query_timeout); w->env->outnet = w->back; if(!w->is_bg || w->is_bg_thread) { lock_basic_unlock(&ctx->cfglock); @@ -454,8 +456,15 @@ fill_res(struct ub_result* res, struct ub_packed_rrset_key* answer, if(rep->rrset_count != 0) res->ttl = (int)rep->ttl; res->data = (char**)calloc(1, sizeof(char*)); + if(!res->data) + return 0; /* out of memory */ 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; if(query_dname_compare(rq->qname, answer->rk.dname) != 0) { @@ -463,15 +472,30 @@ fill_res(struct ub_result* res, struct ub_packed_rrset_key* answer, return 0; /* out of memory */ } else res->canonname = NULL; res->data = (char**)calloc(data->count+1, sizeof(char*)); + if(!res->data) + return 0; /* out of memory */ res->len = (int*)calloc(data->count+1, sizeof(int)); - if(!res->data || !res->len) + if(!res->len) { + free(res->data); + res->data = NULL; return 0; /* out of memory */ + } for(i=0; i<data->count; i++) { /* remove rdlength from rdata */ res->len[i] = (int)(data->rr_len[i] - 2); 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 */ + } } /* ttl for positive answers, from CNAME and answer RRs */ if(data->count != 0) { @@ -877,35 +901,6 @@ struct outbound_entry* libworker_send_query(struct query_info* qinfo, } int -libworker_handle_reply(struct comm_point* c, void* arg, int error, - struct comm_reply* reply_info) -{ - struct module_qstate* q = (struct module_qstate*)arg; - struct libworker* lw = (struct libworker*)q->env->worker; - struct outbound_entry e; - e.qstate = q; - e.qsent = NULL; - - if(error != 0) { - mesh_report_reply(lw->env->mesh, &e, reply_info, error); - return 0; - } - /* sanity check. */ - if(!LDNS_QR_WIRE(sldns_buffer_begin(c->buffer)) - || LDNS_OPCODE_WIRE(sldns_buffer_begin(c->buffer)) != - LDNS_PACKET_QUERY - || LDNS_QDCOUNT(sldns_buffer_begin(c->buffer)) > 1) { - /* error becomes timeout for the module as if this reply - * never arrived. */ - mesh_report_reply(lw->env->mesh, &e, reply_info, - NETEVENT_TIMEOUT); - return 0; - } - mesh_report_reply(lw->env->mesh, &e, reply_info, NETEVENT_NOERROR); - return 0; -} - -int libworker_handle_service_reply(struct comm_point* c, void* arg, int error, struct comm_reply* reply_info) { @@ -947,14 +942,6 @@ int worker_handle_request(struct comm_point* ATTR_UNUSED(c), return 0; } -int worker_handle_reply(struct comm_point* ATTR_UNUSED(c), - void* ATTR_UNUSED(arg), int ATTR_UNUSED(error), - struct comm_reply* ATTR_UNUSED(reply_info)) -{ - log_assert(0); - return 0; -} - int worker_handle_service_reply(struct comm_point* ATTR_UNUSED(c), void* ATTR_UNUSED(arg), int ATTR_UNUSED(error), struct comm_reply* ATTR_UNUSED(reply_info)) diff --git a/libunbound/python/libunbound.i b/libunbound/python/libunbound.i index a23c45b9c708..763879e80869 100644 --- a/libunbound/python/libunbound.i +++ b/libunbound/python/libunbound.i @@ -916,7 +916,13 @@ int _ub_resolve_async(struct ub_ctx* ctx, char* name, int rrtype, int rrclass, v struct cb_data* id; id = (struct cb_data*) iddata; arglist = Py_BuildValue("(OiO)",id->data,status, SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ub_result, 0 | 0 )); // Build argument list +#if PY_MAJOR_VERSION <= 2 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) + /* for python before 3.9 */ fresult = PyEval_CallObject(id->func,arglist); // Call Python +#else + /* for python 3.9 and newer */ + fresult = PyObject_Call(id->func,arglist,NULL); +#endif Py_DECREF(id->func); Py_DECREF(id->data); free(id); @@ -930,6 +936,8 @@ int _ub_resolve_async(struct ub_ctx* ctx, char* name, int rrtype, int rrclass, v int r; struct cb_data* id; id = (struct cb_data*) malloc(sizeof(struct cb_data)); + if(!id) + return -2; /* UB_NOMEM */ id->data = mydata; id->func = pyfunc; diff --git a/libunbound/worker.h b/libunbound/worker.h index fe1d51878a89..bf7473861af8 100644 --- a/libunbound/worker.h +++ b/libunbound/worker.h @@ -75,10 +75,6 @@ struct outbound_entry* libworker_send_query(struct query_info* qinfo, size_t zonelen, int ssl_upstream, char* tls_auth_name, struct module_qstate* q); -/** process incoming replies from the network */ -int libworker_handle_reply(struct comm_point* c, void* arg, int error, - struct comm_reply* reply_info); - /** process incoming serviced query replies from the network */ int libworker_handle_service_reply(struct comm_point* c, void* arg, int error, struct comm_reply* reply_info); @@ -146,10 +142,6 @@ void worker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len, int worker_handle_request(struct comm_point* c, void* arg, int error, struct comm_reply* repinfo); -/** process incoming replies from the network */ -int worker_handle_reply(struct comm_point* c, void* arg, int error, - struct comm_reply* reply_info); - /** process incoming serviced query replies from the network */ int worker_handle_service_reply(struct comm_point* c, void* arg, int error, struct comm_reply* reply_info); |
