diff options
author | Derrell Lipman <derrell@samba.org> | 2005-12-05 23:30:40 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:05:44 -0500 |
commit | a54f9eddcea6497451dd6c720e9804ad5c6f3ad7 (patch) | |
tree | 8efb450c96cb2c41b8eb49003ba81ab225e58834 /source3 | |
parent | 884a0c8226a760e72912ceab159ddc28bd07f62c (diff) | |
download | samba-a54f9eddcea6497451dd6c720e9804ad5c6f3ad7.tar.gz samba-a54f9eddcea6497451dd6c720e9804ad5c6f3ad7.tar.bz2 samba-a54f9eddcea6497451dd6c720e9804ad5c6f3ad7.zip |
r12080: r10673@cabra: derrell | 2005-12-05 13:22:34 -0500
Correct some memory and file descriptor leaks.
This should fix bugs 3257, 3267 and 3273.
(This used to be commit c5781c9cf5f1f8297e084fbe2c4a22257420a447)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libsmb/libsmbclient.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c index f180072a70..f482c9584f 100644 --- a/source3/libsmb/libsmbclient.c +++ b/source3/libsmb/libsmbclient.c @@ -584,9 +584,25 @@ SMBCSRV *smbc_server(SMBCCTX *context, return NULL; } +#if 0 /* choice 1 */ + /* Look for a cached connection, using the provided authinfo */ srv = find_server(context, server, share, workgroup, username, password); + /* If we didn't find one... */ + if (! srv) + { + /* ... then see if there's one using anonymous login */ + fstring anonymous = ""; + srv = find_server(context, server, share, + workgroup, anonymous, password); + } +#else + /* Look for a cached connection */ + srv = find_server(context, server, share, + workgroup, username, password); +#endif + /* * If we found a connection and we're only allowed one share per * server... @@ -780,7 +796,11 @@ SMBCSRV *smbc_server(SMBCCTX *context, /* now add it to the cache (internal or external) */ /* Let the cache function set errno if it wants to */ errno = 0; +#if 0 /* choice 2 */ if (context->callbacks.add_cached_srv_fn(context, srv, server, share, workgroup, username_used)) { +#else + if (context->callbacks.add_cached_srv_fn(context, srv, server, share, workgroup, username)) { +#endif int saved_errno = errno; DEBUG(3, (" Failed to add server to cache\n")); errno = saved_errno; @@ -2169,6 +2189,7 @@ list_unique_wg_fn(const char *name, uint32 type, const char *comment, void *stat /* Found the end of the list. Remove it. */ dir->dir_end = dir_list; free(dir_list->next); + free(dirent); dir_list->next = NULL; break; } @@ -2337,7 +2358,11 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname) * a single master browser. */ + ip_list = NULL; if (!name_resolve_bcast(MSBROWSE, 1, &ip_list, &count)) { + + SAFE_FREE(ip_list); + if (!find_master_ip(workgroup, &server_addr.ip)) { errno = ENOENT; @@ -2383,9 +2408,16 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname) if (!cli_NetServerEnum(&srv->cli, workgroup, SV_TYPE_DOMAIN_ENUM, list_unique_wg_fn, (void *)dir)) { + if (dir) { + SAFE_FREE(dir->fname); + SAFE_FREE(dir); + } + continue; } } + + SAFE_FREE(ip_list); } else { /* * Server not an empty string ... Check the rest and see what |