]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:utils: smbget fix a memory leak
authorJones Syue <jonessyue@qnap.com>
Tue, 27 Jun 2023 09:19:59 +0000 (17:19 +0800)
committerVolker Lendecke <vl@samba.org>
Wed, 28 Jun 2023 07:02:34 +0000 (07:02 +0000)
Using smbget to download files recursively (-R).

If smbget found that a file is already existed in the destination,
smbget would said 'File exists', return early, and 'newname' allocated
memory is never freed, this is found by valgrind.

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

Signed-off-by: Jones Syue <jonessyue@qnap.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Jun 28 07:02:34 UTC 2023 on atb-devel-224

source3/utils/smbget.c

index 00bf20e8192118407d02d82671897ca9f845a7a6..5c99dcf918a3eb426d28c5ed1a4a6036da4c7202 100644 (file)
@@ -246,6 +246,7 @@ static bool smb_download_dir(const char *base, const char *name, int resume)
                if (!ok) {
                        fprintf(stderr, "Failed to download %s: %s\n",
                                newname, strerror(errno));
+                       free(newname);
                        free(tmpname);
                        return false;
                }