ctdb: Fix posible NULL deref in logging_init()
authorAndreas Schneider <asn@samba.org>
Thu, 16 Feb 2017 16:38:41 +0000 (17:38 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 23 Feb 2017 18:56:05 +0000 (19:56 +0100)
Found by covscan.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12592

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
ctdb/common/logging.c

index 3d586bfb49bd64bdc396f244b3305c65a0169a5c..c8ccf26b565dd1d89cc5935453e68acbf8f934cb 100644 (file)
@@ -521,7 +521,14 @@ int logging_init(TALLOC_CTX *mem_ctx, const char *logging,
        }
 
        name = strtok(str, ":");
+       if (name == NULL) {
+               return EINVAL;
+       }
        option = strtok(NULL, ":");
+       /*
+        * option can be NULL here, both setup()
+        * backends handle this.
+        */
 
        for (i=0; i<ARRAY_SIZE(log_backend); i++) {
                if (strcmp(log_backend[i].name, name) == 0) {