ctdb-cluster: CID 1435726: NULL pointer dereference
authorMartin Schwenke <martin@meltin.net>
Wed, 29 May 2019 07:38:03 +0000 (17:38 +1000)
committerAmitay Isaacs <amitay@samba.org>
Wed, 5 Jun 2019 10:25:50 +0000 (10:25 +0000)
Also found by csbuild.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/cluster/cluster_conf.c

index 540732d5b9191db9d404a2560bc5b2de04ca6598..be79d5942a846b336f007bdef6c992011bf21486 100644 (file)
@@ -38,13 +38,24 @@ static bool check_static_string_change(const char *key,
                                       enum conf_update_mode mode)
 {
        if (mode == CONF_MODE_RELOAD) {
-               if (strcmp(old_value, new_value) != 0) {
+               if (old_value == new_value) {
+                       goto done;
+               }
+
+               /*
+                * At this point old_value or new_value can not both
+                * NULL, so if one is NULL then they are different
+                */
+               if (old_value == NULL ||
+                   new_value == NULL ||
+                   strcmp(old_value, new_value) != 0) {
                        D_WARNING("Ignoring update of [%s] -> %s\n",
                                  CLUSTER_CONF_SECTION,
                                  key);
                }
        }
 
+done:
        return true;
 }