diff --git a/CHANGES b/CHANGES index 77d5a75b31..b01ed0d236 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4070. [bug] Fix a segfault in nslookup in a query such as + "nslookup isc.org AMS.SNS-PB.ISC.ORG -all". + [RT #38548] + 4069. [doc] Reorganize options in the nsupdate man page. [RT #38516] diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 3fa519a1dd..d317a3a7a3 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -3924,10 +3924,14 @@ isc_result_t get_address(char *host, in_port_t myport, isc_sockaddr_t *sockaddr) { int count; isc_result_t result; + isc_boolean_t is_running; - isc_app_block(); + is_running = isc_app_isrunning(); + if (is_running) + isc_app_block(); result = bind9_getaddresses(host, myport, sockaddr, 1, &count); - isc_app_unblock(); + if (is_running) + isc_app_unblock(); if (result != ISC_R_SUCCESS) return (result); diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index d3237fa5dc..30591dc556 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -585,7 +585,7 @@ version(void) { static void setoption(char *opt) { - if (strncasecmp(opt, "all", 4) == 0) { + if (strncasecmp(opt, "all", 3) == 0) { show_settings(ISC_TRUE, ISC_FALSE); } else if (strncasecmp(opt, "class=", 6) == 0) { if (testclass(&opt[6])) diff --git a/lib/isc/app_api.c b/lib/isc/app_api.c index 46b9128f5d..a85d0b80c5 100644 --- a/lib/isc/app_api.c +++ b/lib/isc/app_api.c @@ -29,6 +29,7 @@ static isc_mutex_t createlock; static isc_once_t once = ISC_ONCE_INIT; static isc_appctxcreatefunc_t appctx_createfunc = NULL; +static isc_boolean_t is_running = ISC_FALSE; #define ISCAPI_APPMETHODS_VALID(m) ISC_MAGIC_VALID(m, ISCAPI_APPMETHODS_MAGIC) @@ -198,12 +199,24 @@ isc_app_onrun(isc_mem_t *mctx, isc_task_t *task, isc_result_t isc_app_run() { - if (isc_bind9) - return (isc__app_run()); + if (isc_bind9) { + isc_result_t result; + + is_running = ISC_TRUE; + result = isc__app_run(); + is_running = ISC_FALSE; + + return (result); + } return (ISC_R_NOTIMPLEMENTED); } +isc_boolean_t +isc_app_isrunning() { + return (is_running); +} + isc_result_t isc_app_shutdown(void) { if (isc_bind9) diff --git a/lib/isc/include/isc/app.h b/lib/isc/include/isc/app.h index baefb82c2d..477b5eae2f 100644 --- a/lib/isc/include/isc/app.h +++ b/lib/isc/include/isc/app.h @@ -203,6 +203,16 @@ isc_app_run(void); *\li ISC_R_RELOAD Reload has been requested. */ +isc_boolean_t +isc_app_isrunning(void); +/*!< + * \brief Return if the ISC library application is running. + * + * Returns: + *\li ISC_TRUE App is running. + *\li ISC_FALSE App is not running. + */ + isc_result_t isc_app_ctxshutdown(isc_appctx_t *ctx); diff --git a/lib/isc/win32/libisc.def.in b/lib/isc/win32/libisc.def.in index 708dc3118a..ea6990551c 100644 --- a/lib/isc/win32/libisc.def.in +++ b/lib/isc/win32/libisc.def.in @@ -120,6 +120,7 @@ isc_app_ctxshutdown isc_app_ctxstart isc_app_ctxsuspend isc_app_finish +isc_app_isrunning isc_app_onrun isc_app_register isc_app_reload