s3-gencache: restore gencache_get behavior with NULL args (with torture test).
authorGünther Deschner <gd@samba.org>
Mon, 2 Nov 2009 12:01:58 +0000 (13:01 +0100)
committerGünther Deschner <gd@samba.org>
Mon, 2 Nov 2009 12:04:26 +0000 (13:04 +0100)
Without this, we panic in wins_srv_is_dead() and fail to start nmbd with
wins support.

Volker, please check.

Guenther

source3/lib/gencache.c
source3/torture/torture.c

index 6de653fa17d370abcf9adf5f31d17a4cd1afde1f..4889d7ca62fbd5d4d270833d979c355d72bf77cd 100644 (file)
@@ -529,11 +529,15 @@ bool gencache_get(const char *keystr, char **value, time_t *ptimeout)
                SAFE_FREE(blob.data);
                return false;
        }
-       *value = SMB_STRDUP((char *)blob.data);
-       data_blob_free(&blob);
-       if (*value == NULL) {
-               return false;
+       if (value) {
+               *value = SMB_STRDUP((char *)blob.data);
+               data_blob_free(&blob);
+               if (*value == NULL) {
+                       return false;
+               }
+               return true;
        }
+       data_blob_free(&blob);
        return true;
 }
 
index ca499a9fcc8326f141a2e7bc2ee7491ceb30a99e..bda82f2b7494504f90d5c04a09dc60b1b21aa530 100644 (file)
@@ -6431,6 +6431,11 @@ static bool run_local_gencache(int dummy)
                return False;
        }
 
+       if (!gencache_get("foo", NULL, NULL)) {
+               d_printf("%s: gencache_get() failed\n", __location__);
+               return False;
+       }
+
        if (!gencache_get("foo", &val, &tm)) {
                d_printf("%s: gencache_get() failed\n", __location__);
                return False;