mirror of
https://github.com/samba-team/samba.git
synced 2025-12-10 04:23:50 +03:00
fix a bunch of places where we can double-free a cli structure
This commit is contained in:
@@ -110,8 +110,6 @@ static void free_server_private_data(void **private_data_pointer)
|
||||
struct cli_state **cli = (struct cli_state **)private_data_pointer;
|
||||
if (*cli && (*cli)->initialised) {
|
||||
cli_shutdown(*cli);
|
||||
|
||||
SAFE_FREE(*cli);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +127,6 @@ static void send_server_keepalive(void **private_data_pointer)
|
||||
if (!send_keepalive((*cli)->fd)) {
|
||||
DEBUG( 2, ( "password server keepalive failed.\n"));
|
||||
cli_shutdown(*cli);
|
||||
SAFE_FREE(*cli);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -346,7 +343,6 @@ use this machine as the password server.\n"));
|
||||
|
||||
if (locally_made_cli) {
|
||||
cli_shutdown(cli);
|
||||
SAFE_FREE(cli);
|
||||
}
|
||||
|
||||
return(nt_status);
|
||||
|
||||
@@ -2124,7 +2124,6 @@ struct cli_state *do_connect(const char *server, const char *share)
|
||||
d_printf("session request to %s failed (%s)\n",
|
||||
called.name, cli_errstr(c));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
if ((p=strchr_m(called.name, '.'))) {
|
||||
*p = 0;
|
||||
goto again;
|
||||
@@ -2141,7 +2140,6 @@ struct cli_state *do_connect(const char *server, const char *share)
|
||||
if (!cli_negprot(c)) {
|
||||
d_printf("protocol negotiation failed\n");
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2161,7 +2159,6 @@ struct cli_state *do_connect(const char *server, const char *share)
|
||||
!cli_session_setup(c, "", "", 0, "", 0, workgroup)) {
|
||||
d_printf("session setup failed: %s\n", cli_errstr(c));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
d_printf("Anonymous login successful\n");
|
||||
@@ -2186,7 +2183,6 @@ struct cli_state *do_connect(const char *server, const char *share)
|
||||
password, strlen(password)+1)) {
|
||||
d_printf("tree connect failed: %s\n", cli_errstr(c));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,6 @@ static struct cli_state *do_connection(char *the_service)
|
||||
DEBUG(0,("%d: Connection to %s failed\n", getpid(), server_n));
|
||||
if (c) {
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -159,7 +158,6 @@ static struct cli_state *do_connection(char *the_service)
|
||||
DEBUG(0,("%d: session request to %s failed (%s)\n",
|
||||
getpid(), called.name, cli_errstr(c)));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
if ((p=strchr_m(called.name, '.'))) {
|
||||
*p = 0;
|
||||
goto again;
|
||||
@@ -176,7 +174,6 @@ static struct cli_state *do_connection(char *the_service)
|
||||
if (!cli_negprot(c)) {
|
||||
DEBUG(0,("%d: protocol negotiation failed\n", getpid()));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -198,7 +195,6 @@ static struct cli_state *do_connection(char *the_service)
|
||||
DEBUG(0,("%d: session setup failed: %s\n",
|
||||
getpid(), cli_errstr(c)));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
DEBUG(0,("Anonymous login successful\n"));
|
||||
@@ -211,7 +207,6 @@ static struct cli_state *do_connection(char *the_service)
|
||||
DEBUG(0,("%d: tree connect failed: %s\n",
|
||||
getpid(), cli_errstr(c)));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -360,7 +355,6 @@ static void send_fs_socket(char *the_service, char *mount_point, struct cli_stat
|
||||
If we don't do this we will "leak" sockets and memory on
|
||||
each reconnection we have to make. */
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
|
||||
if (!closed) {
|
||||
/* redirect stdout & stderr since we can't know that
|
||||
|
||||
@@ -270,7 +270,7 @@ static int ads_add_machine_acct(ADS_STRUCT *ads, const char *hostname)
|
||||
asprintf(&new_dn, "cn=%s,cn=Computers,%s", hostname, ads->bind_path);
|
||||
asprintf(&samAccountName, "%s$", hostname);
|
||||
asprintf(&controlstr, "%u",
|
||||
UF_DONT_EXPIRE_PASSWD | UF_WORKSTATION_TRUST_ACCOUNT |
|
||||
UF_DONT_EXPIRE_PASSWD | UF_WORKSTATION_TRUST_ACCOUNT |
|
||||
UF_TRUSTED_FOR_DELEGATION | UF_USE_DES_KEY_ONLY);
|
||||
|
||||
ret = ads_gen_add(ads, new_dn,
|
||||
@@ -466,4 +466,17 @@ NTSTATUS ads_set_machine_password(ADS_STRUCT *ads,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* find the update serial number - this is the core of the ldap cache */
|
||||
BOOL ads_USN(ADS_STRUCT *ads, unsigned *usn)
|
||||
{
|
||||
const char *attrs[] = {"highestCommittedUSN", NULL};
|
||||
int rc;
|
||||
void *res;
|
||||
|
||||
rc = ldap_search_s(ads->ld, ads->bind_path,
|
||||
LDAP_SCOPE_BASE, "(objectclass=*)", (char **)attrs, 0, (LDAPMessage *)&res);
|
||||
if (rc || ads_count_replies(ads, res) != 1) return False;
|
||||
return False;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1144,7 +1144,7 @@ BOOL cli_establish_connection(struct cli_state *cli,
|
||||
{
|
||||
DEBUG(1,("failed tcon_X\n"));
|
||||
if (do_shutdown)
|
||||
cli_shutdown(cli);
|
||||
cli_shutdown(cli);
|
||||
return False;
|
||||
}
|
||||
}
|
||||
@@ -1196,9 +1196,9 @@ BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char
|
||||
|
||||
DEBUG(0,("attempt_netbios_session_request: %s rejected the session for name *SMBSERVER \
|
||||
with error %s.\n", desthost, cli_errstr(cli) ));
|
||||
cli_shutdown(cli);
|
||||
return False;
|
||||
}
|
||||
cli_shutdown(cli);
|
||||
return False;
|
||||
}
|
||||
|
||||
cli_shutdown(cli);
|
||||
|
||||
|
||||
@@ -249,7 +249,6 @@ static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NS
|
||||
}
|
||||
cli_ulogoff(cli[server][conn]);
|
||||
cli_shutdown(cli[server][conn]);
|
||||
SAFE_FREE(cli[server][conn]);
|
||||
}
|
||||
cli[server][conn] = connect_one(share[server]);
|
||||
if (!cli[server][conn]) {
|
||||
|
||||
@@ -266,7 +266,6 @@ static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS],
|
||||
}
|
||||
cli_ulogoff(cli[server][conn]);
|
||||
cli_shutdown(cli[server][conn]);
|
||||
SAFE_FREE(cli[server][conn]);
|
||||
}
|
||||
cli[server][conn] = connect_one(share[server]);
|
||||
if (!cli[server][conn]) {
|
||||
|
||||
@@ -381,7 +381,6 @@ again:
|
||||
DEBUG(1,("session request to %s failed (%s)\n",
|
||||
called.name, cli_errstr(c)));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
if ((p=strchr(called.name, '.'))) {
|
||||
*p = 0;
|
||||
goto again;
|
||||
@@ -398,7 +397,6 @@ again:
|
||||
if (!cli_negprot(c)) {
|
||||
DEBUG(1,("protocol negotiation failed\n"));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -417,7 +415,6 @@ again:
|
||||
if (!cli_session_setup(c, "", "", 0, "", 0, opt_workgroup)) {
|
||||
DEBUG(1,("session setup failed: %s\n", cli_errstr(c)));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
DEBUG(3,("Anonymous login successful\n"));
|
||||
@@ -428,7 +425,6 @@ again:
|
||||
opt_password, strlen(opt_password)+1)) {
|
||||
DEBUG(1,("tree connect failed: %s\n", cli_errstr(c)));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -710,14 +710,12 @@ struct cli_state *connect_one(char *share)
|
||||
if (!(c=cli_initialise(NULL)) || !cli_connect(c, server, &ip)) {
|
||||
DEBUG(0,("Connection to %s failed\n", server));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!cli_session_request(c, &calling, &called)) {
|
||||
DEBUG(0,("session request to %s failed\n", called.name));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
if (strcmp(called.name, "*SMBSERVER")) {
|
||||
make_nmb_name(&called , "*SMBSERVER", 0x20);
|
||||
goto again;
|
||||
@@ -730,7 +728,6 @@ struct cli_state *connect_one(char *share)
|
||||
if (!cli_negprot(c)) {
|
||||
DEBUG(0,("protocol negotiation failed\n"));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -747,7 +744,6 @@ struct cli_state *connect_one(char *share)
|
||||
lp_workgroup())) {
|
||||
DEBUG(0,("session setup failed: %s\n", cli_errstr(c)));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -757,7 +753,6 @@ struct cli_state *connect_one(char *share)
|
||||
password, strlen(password)+1)) {
|
||||
DEBUG(0,("tree connect failed: %s\n", cli_errstr(c)));
|
||||
cli_shutdown(c);
|
||||
SAFE_FREE(c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,6 @@ static struct cli_state *get_ipc_connect(char *server,
|
||||
if (cli && cli->initialised)
|
||||
cli_shutdown(cli);
|
||||
|
||||
SAFE_FREE(cli);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user