s3: smbd: Fix memory leak in vfswrap_getwd()
authorJeremy Allison <jra@samba.org>
Fri, 6 Apr 2018 20:52:52 +0000 (13:52 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 9 Apr 2018 19:48:12 +0000 (21:48 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13372

Signed-off-by: Andrew Walker <awalker@ixsystems.com>.
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Apr  9 21:48:12 CEST 2018 on sn-devel-144

source3/modules/vfs_default.c

index a26bec457ae59dadc5dc82c316eb6b4106781526..a9c87e444fe43e0f67a27612efb94edec41d948b 100644 (file)
@@ -2229,9 +2229,12 @@ static struct smb_filename *vfswrap_getwd(vfs_handle_struct *handle,
                                NULL,
                                NULL,
                                0);
-       if (smb_fname == NULL) {
-               SAFE_FREE(result);
-       }
+       /*
+        * sys_getwd() *always* returns malloced memory.
+        * We must free here to avoid leaks:
+        * BUG:https://bugzilla.samba.org/show_bug.cgi?id=13372
+        */
+       SAFE_FREE(result);
        return smb_fname;
 }