s3: smbd: dfs: Allow parse_msdfs_symlink() to be called with NULL pointers.
authorJeremy Allison <jra@samba.org>
Tue, 28 Jan 2020 00:45:20 +0000 (16:45 -0800)
committerRalph Boehme <slow@samba.org>
Tue, 18 Feb 2020 21:08:33 +0000 (21:08 +0000)
In case we don't want all the data.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/msdfs.c

index 2d784430ebf8bf51a9a0cd11427b6248b396f51e..4df881bd87e70cd68c564ef38608f8f2d95d30de 100644 (file)
@@ -565,14 +565,14 @@ bool parse_msdfs_symlink(TALLOC_CTX *ctx,
        DBG_DEBUG("count=%zu\n", count);
 
        if (count) {
-               reflist = *preflist = talloc_zero_array(ctx,
+               reflist = talloc_zero_array(ctx,
                                struct referral, count);
                if(reflist == NULL) {
                        TALLOC_FREE(alt_path);
                        return false;
                }
        } else {
-               reflist = *preflist = NULL;
+               reflist = NULL;
        }
 
        for(i=0;i<count;i++) {
@@ -601,8 +601,12 @@ bool parse_msdfs_symlink(TALLOC_CTX *ctx,
                        reflist[i].alternate_path);
        }
 
-       *refcount = count;
-
+       if (preflist != NULL) {
+               *preflist = reflist;
+       }
+       if (refcount != NULL) {
+               *refcount = count;
+       }
        TALLOC_FREE(alt_path);
        return true;
 }