]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix a segfault when running nslookup (#38548)
authorMukund Sivaraman <muks@isc.org>
Thu, 26 Feb 2015 08:30:57 +0000 (14:00 +0530)
committerMukund Sivaraman <muks@isc.org>
Thu, 26 Feb 2015 08:33:35 +0000 (14:03 +0530)
CHANGES
bin/dig/dighost.c
bin/dig/nslookup.c
lib/isc/app_api.c
lib/isc/include/isc/app.h
lib/isc/win32/libisc.def.in

diff --git a/CHANGES b/CHANGES
index b755d23974e8474da798cd8d39f31994206a94f6..3596ea54a2fd8fc34254a2d655d52f1c1209d083 100644 (file)
--- 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]
 
index d790a2e3b122f24173919c9d8e070564873a4b27..fd025800162b371c6813d3bdfbdf18c2d6fdab9d 100644 (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);
 
index 88d216cee5fa1cd45f6df31eb689b87333c3d98b..0d364becc284bde0902d3506a403b051002e3cb0 100644 (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]))
index 46b9128f5d802a98f8859c8363fc78628d58c37e..a85d0b80c5b7e8f85f2589b256117b1632bcff23 100644 (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)
index baefb82c2d4c24f419864aeb48a42354ed90517f..477b5eae2ff3983c1073f639f5a443a576163a83 100644 (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);
 
index e810050384ddddd0e63316d8dbe5fea728c49cbc..7a5e2424235d999b482a71f02a977d2bdc285ec7 100644 (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