Patch for attempt_netbios_session_request() related crash
Kim R. Pedersen
krp at filanet.dk
Tue Sep 3 11:30:00 GMT 2002
Hello Samba-Fans,
During my port of Samba to my company's new platform, I came across this bug
in 2.2.5 that I think someone else reported too.
When Samba tries to connect to a password server (security = server or domain)
and the connection failes samba crashes some time after
attempt_netbios_session_request().
The problem is that the *cli structure is being freed in cli_shutdown() and
then reused in cli_initialized() during the attempt to connect a second time.
I have therefore added a function cli_shutdown_nofree() that will save the
allocated flag and prevent cli_shutdown() from freeing the structure.
I don't think this is a very clean solution, but changing the way cli
structures are allocated and freed is a major undertaking, that is best left
for the Samba team. (I personally dislike the way cli_initialize() and
cli_shutdown() might allocate and free the cli structure).
Regards
Kimrp, Filanet Europe
--- libsmb/cliconnect.c-2.2.5 Tue Sep 3 12:58:49 2002
+++ libsmb/cliconnect.c-fix Tue Sep 3 13:17:02 2002
@@ -1042,6 +1042,15 @@
Attempt a NetBIOS session request, falling back to *SMBSERVER if needed.
****************************************************************************/
+static void cli_shutdown_nofree(struct cli_state *cli)
+{
+ BOOL allocated = cli->allocated;
+
+ cli->allocated = False;
+ cli_shutdown(cli);
+ cli->allocated = allocated;
+}
+
BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost,
char *desthost,
struct in_addr *pdest_ip)
{
@@ -1082,7 +1091,7 @@
return False;
}
- cli_shutdown(cli);
+ cli_shutdown_nofree(cli);
if (!cli_initialise(cli) || !cli_connect(cli, desthost, pdest_ip) ||
!cli_session_request(cli, &calling, &smbservername))
More information about the samba-technical
mailing list