From: W.C.A. Wijngaards Date: Tue, 16 Jun 2026 08:44:41 +0000 (+0200) Subject: - Fix that libunbound pipe functions fail with error after X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9b9e13b6655c7f8c206407c19cdf5f9a79b74e08;p=thirdparty%2Funbound.git - Fix that libunbound pipe functions fail with error after an event base is set. Thanks to Qifan Zhang, Palo Alto Networks, for the report. --- diff --git a/doc/Changelog b/doc/Changelog index 0bcd8a182..0ecba8b5d 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -38,6 +38,9 @@ Alto Networks, for the report. - Fix locking in libunbound ub_ctx_set_event call. Thanks to Qifan Zhang, Palo Alto Networks, for the report. + - Fix that libunbound pipe functions fail with error after + an event base is set. Thanks to Qifan Zhang, Palo Alto + Networks, for the report. 15 June 2026: Wouter - Fix to add `max-transfer-size` and `max-transfer-time` that diff --git a/libunbound/libunbound.c b/libunbound/libunbound.c index 8431b6bb1..140a45233 100644 --- a/libunbound/libunbound.c +++ b/libunbound/libunbound.c @@ -571,6 +571,8 @@ ub_ctx_async(struct ub_ctx* ctx, int dothread) int ub_poll(struct ub_ctx* ctx) { + if(!ctx || ctx->event_base) + return UB_INITFAIL; /* no need to hold lock while testing for readability. */ return tube_poll(ctx->rr_pipe); } @@ -578,6 +580,8 @@ ub_poll(struct ub_ctx* ctx) int ub_fd(struct ub_ctx* ctx) { + if(!ctx || ctx->event_base) + return -1; return tube_read_fd(ctx->rr_pipe); } @@ -672,6 +676,8 @@ ub_process(struct ub_ctx* ctx) int r; uint8_t* msg; uint32_t len; + if(!ctx || ctx->event_base) + return UB_INITFAIL; while(1) { msg = NULL; lock_basic_lock(&ctx->rrpipe_lock); @@ -700,6 +706,8 @@ ub_wait(struct ub_ctx* ctx) int r; uint8_t* msg; uint32_t len; + if(!ctx || ctx->event_base) + return UB_INITFAIL; /* this is basically the same loop as _process(), but with changes. * holds the rrpipe lock and waits with tube_wait */ while(1) { @@ -837,6 +845,8 @@ ub_resolve_async(struct ub_ctx* ctx, const char* name, int rrtype, struct ctx_query* q; uint8_t* msg = NULL; uint32_t len = 0; + if(!ctx || ctx->event_base) + return UB_INITFAIL; if(async_id) *async_id = 0;