Skip to content

Commit a663d07

Browse files
cryptomilkanoopcs9
authored andcommitted
s3:client: Use talloc to avoid memory leaks in smbspool
The function uri_unescape_alloc() is called by main() which has a talloc stackframe. Direct leak of 13 byte(s) in 1 object(s) allocated from: #0 0x7fc31351b9a0 in strdup (/lib64/libasan.so.8+0x11b9a0) (BuildId: 388ee9ac193f74c177c6f52988d2d0dab110de41) #1 0x7fc3129cfb50 in smb_xstrdup ../../lib/util/util.c:760 #2 0x0000002059f8 in uri_unescape_alloc ../../source3/client/smbspool.c:888 #3 0x00000020752a in main ../../source3/client/smbspool.c:347 #4 0x7fc30f62b2fa in __libc_start_call_main (/lib64/libc.so.6+0x2b2fa) (BuildId: 8523b213e7586a93ab00f6dd476418b1e521e62c) #5 0x7ffd8bb806be ([stack]+0x3b6be) Signed-off-by: Andreas Schneider <[email protected]> Reviewed-by: Anoop C S <[email protected]> Autobuild-User(master): Anoop C S <[email protected]> Autobuild-Date(master): Fri Oct 24 07:42:37 UTC 2025 on atb-devel-224
1 parent ba87122 commit a663d07

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

source3/client/smbspool.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -883,16 +883,14 @@ smb_print(struct cli_state * cli, /* I - SMB connection */
883883
static char *
884884
uri_unescape_alloc(const char *uritok)
885885
{
886-
char *ret;
887-
char *end;
888-
ret = (char *) SMB_STRDUP(uritok);
886+
char *end = NULL;
887+
char *ret = talloc_strdup(talloc_tos(), uritok);
889888
if (!ret) {
890889
return NULL;
891890
}
892891

893892
end = rfc1738_unescape(ret);
894893
if (end == NULL) {
895-
free(ret);
896894
return NULL;
897895
}
898896
return ret;

0 commit comments

Comments
 (0)