Fix a segfault when running nslookup (#38548)

This commit is contained in:
Mukund Sivaraman 2015-02-26 14:00:57 +05:30
parent bef771f237
commit db93c0def5
6 changed files with 37 additions and 5 deletions

View file

@ -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]

View file

@ -4047,10 +4047,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);

View file

@ -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]))

View file

@ -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)

View file

@ -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);

View file

@ -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