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. patch will follow. # valgrind --leak-check=full --show-leak-kinds=definite smbget -R -U${ac}%${pw} smb://${ip}/src ==13050== Memcheck, a memory error detector ==13050== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==13050== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info ==13050== Command: smbget -R -Ujones%${pw} smb://127.0.0.1/src ==13050== Using workgroup WORKGROUP, user jones Can't open file: File exists Failed to download /file: File exists ==13050== ==13050== HEAP SUMMARY: ==13050== in use at exit: 121,424 bytes in 263 blocks ==13050== total heap usage: 5,466 allocs, 5,203 frees, 927,883 bytes allocated ==13050== ==13050== 6 bytes in 1 blocks are definitely lost in loss record 6 of 151 ==13050== at 0x4C28B15: malloc (in /root/bin/valgrind-3.12.0/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==13050== by 0x5B7E9D7: vasprintf (vasprintf.c:76) ==13050== by 0x5B5D2C6: asprintf (asprintf.c:35) ==13050== by 0x10BC29: smb_download_dir (smbget.c:211) ==13050== by 0x10A549: main (smbget.c:1037) ==13050== ... <cut> ...
patch against master: https://gitlab.com/samba-team/devel/samba/-/commit/5e0c48ac ci pipeline is passed: https://gitlab.com/samba-team/devel/samba/-/pipelines/912971149 merge request: https://gitlab.com/samba-team/samba/-/merge_requests/3147
MR LGTM. I'll push once I get a second Team reviewer.
This bug was referenced in samba master: afbed653526b572f7309e67ed742a76ef7b2b8ec
Created attachment 17959 [details] Patch
Comment on attachment 17959 [details] Patch LGTM.
Re-assigning to Jule for inclusion in 4.18.next, 4.17.next.
Pushed to autobuild-v4-{18,17}-test.
This bug was referenced in samba v4-17-test: 88c24655c7966af129b679535f181c7779ce0eef
This bug was referenced in samba v4-18-test: 29c08b5891d984dad1935dbf1ac72c1bb384ff88
Closing out bug report. Thanks!
This bug was referenced in samba v4-18-stable (Release samba-4.18.4): 29c08b5891d984dad1935dbf1ac72c1bb384ff88
This bug was referenced in samba v4-17-stable (Release samba-4.17.9): 88c24655c7966af129b679535f181c7779ce0eef