]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix assertion failure when using -X none and lock-file in configuration
authorAram Sargsyan <aram@isc.org>
Thu, 26 Oct 2023 12:21:57 +0000 (12:21 +0000)
committerAram Sargsyan <aram@isc.org>
Thu, 26 Oct 2023 12:21:57 +0000 (12:21 +0000)
When 'lock-file <lockfile>' is used in configuration at the same time
as using '-X none' in 'named' invocation, there is an invalid
logic that would lead to a isc_mem_strdup() call on a NULL value.

Also, contradicting to ARM, 'lock-file none' is overriding the '-X'
argument.

Fix the overall logic, and make sure that the '-X' takes precedence to
'lock-file'.

bin/named/server.c

index e2d49b7341dd5c0cf9e823d0cad245363fed1b8f..61d782d9dd4140b4d4bd337e17fa06be640fc410 100644 (file)
@@ -8166,27 +8166,24 @@ check_lockfile(named_server_t *server, const cfg_obj_t *config,
        }
 
        if (obj != NULL) {
-               if (cfg_obj_isvoid(obj)) {
-                       isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
-                                     NAMED_LOGMODULE_SERVER, ISC_LOG_DEBUG(1),
-                                     "skipping lock-file check ");
-                       return (ISC_R_SUCCESS);
-               } else if (named_g_forcelock) {
+               if (named_g_forcelock) {
                        isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
                                      NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
                                      "'lock-file' has no effect "
                                      "because the server was run with -X");
-                       server->lockfile = isc_mem_strdup(
-                               server->mctx, named_g_defaultlockfile);
-               } else {
+                       if (named_g_defaultlockfile != NULL) {
+                               server->lockfile = isc_mem_strdup(
+                                       server->mctx, named_g_defaultlockfile);
+                       }
+               } else if (cfg_obj_isvoid(obj)) {
+                       isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
+                                     NAMED_LOGMODULE_SERVER, ISC_LOG_DEBUG(1),
+                                     "skipping lock-file check");
+               } else if (cfg_obj_isstring(obj)) {
                        filename = cfg_obj_asstring(obj);
                        server->lockfile = isc_mem_strdup(server->mctx,
                                                          filename);
                }
-
-               if (server->lockfile == NULL) {
-                       return (ISC_R_NOMEMORY);
-               }
        } else if (named_g_forcelock && named_g_defaultlockfile != NULL) {
                server->lockfile = isc_mem_strdup(server->mctx,
                                                  named_g_defaultlockfile);