summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-11-28 03:56:30 +0000
committerAndrew Tridgell <tridge@samba.org>2001-11-28 03:56:30 +0000
commiteec9e8a052407611df223fec982588e7a2bd7f49 (patch)
tree70742ae3dd80f86aca5b61afc079811d8aa2f826
parenta6b73b9767524fa6997bd31398d558a7cf1e4ac8 (diff)
downloadsamba-eec9e8a052407611df223fec982588e7a2bd7f49.tar.gz
samba-eec9e8a052407611df223fec982588e7a2bd7f49.tar.bz2
samba-eec9e8a052407611df223fec982588e7a2bd7f49.zip
fix a bunch of places where we can double-free a cli structure
(This used to be commit e2ba2383c9f679c076749a8f4fccefc3559e37ec)
-rw-r--r--source3/auth/auth_server.c4
-rw-r--r--source3/client/client.c4
-rw-r--r--source3/client/smbmount.c6
-rw-r--r--source3/libads/ldap.c15
-rw-r--r--source3/libsmb/cliconnect.c8
-rw-r--r--source3/torture/locktest.c1
-rw-r--r--source3/torture/locktest2.c1
-rw-r--r--source3/utils/net.c4
-rw-r--r--source3/utils/smbcacls.c5
-rw-r--r--source3/utils/smbtree.c1
10 files changed, 18 insertions, 31 deletions
diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c
index 628e672608..4608c639eb 100644
--- a/source3/auth/auth_server.c
+++ b/source3/auth/auth_server.c
@@ -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);
diff --git a/source3/client/client.c b/source3/client/client.c
index 2b0867cf7b..c3d1fbc7ec 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -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;
}
diff --git a/source3/client/smbmount.c b/source3/client/smbmount.c
index 3aeddfabca..02db69dfd5 100644
--- a/source3/client/smbmount.c
+++ b/source3/client/smbmount.c
@@ -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
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 604a11aa5b..49e803a49d 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -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
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 314ac6638a..ba4bedf8ab 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -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);
diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c
index 8606c9e38a..4e5d630f30 100644
--- a/source3/torture/locktest.c
+++ b/source3/torture/locktest.c
@@ -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]) {
diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c
index 49c8b2a8a9..175039bd14 100644
--- a/source3/torture/locktest2.c
+++ b/source3/torture/locktest2.c
@@ -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]) {
diff --git a/source3/utils/net.c b/source3/utils/net.c
index 02373c7051..5a92766fa5 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -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;
}
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index 2605442e8a..670e1f6efe 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -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;
}
diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c
index 5b7e8a73c1..b06920418d 100644
--- a/source3/utils/smbtree.c
+++ b/source3/utils/smbtree.c
@@ -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;
}