From f452de7ed622669ce203b58e5a528a0933da58ac Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 9 Feb 2000 15:43:09 +0000 Subject: Correct for for core dump in smbpasswd with cli_errstr(). Jeremy.plit the test for NetBIOS name being *SMBSERVER. (This used to be commit 34b0e2acb050e384c132ddfb50ec84157fb430c6) --- source3/libsmb/clientgen.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'source3/libsmb/clientgen.c') diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index b1d8f8aa73..0b669715b9 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -2693,9 +2693,12 @@ int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_ if (num ) *num = 0; if (nt_rpc_error) *nt_rpc_error = 0; - if(!cli || !cli->initialised || !cli->inbuf) + if(cli->initialised) return EINVAL; + if(!cli->inbuf) + return ENOMEM; + flgs2 = SVAL(cli->inbuf,smb_flg2); if (nt_rpc_error) *nt_rpc_error = cli->nt_error; @@ -3225,7 +3228,7 @@ BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail) ****************************************************************************/ BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char *desthost, - struct in_addr *pdest_ip) + struct in_addr *pdest_ip) { struct nmb_name calling, called; @@ -3244,21 +3247,32 @@ BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char if (!cli_session_request(cli, &calling, &called)) { struct nmb_name smbservername; + make_nmb_name(&smbservername , "*SMBSERVER", 0x20); + /* * If the name wasn't *SMBSERVER then * try with *SMBSERVER if the first name fails. */ - cli_shutdown(cli); + if (nmb_name_equal(&called, &smbservername)) { - make_nmb_name(&smbservername , "*SMBSERVER", 0x20); + /* + * The name used was *SMBSERVER, don't bother with another name. + */ + + DEBUG(0,("attempt_netbios_session_request: %s rejected the session for name %s \ +with error %s.\n", desthost, cli_errstr(cli) )); + cli_shutdown(cli); + return False; + } + + cli_shutdown(cli); - if (!nmb_name_equal(&called, &smbservername) || - !cli_initialise(cli) || + if (!cli_initialise(cli) || !cli_connect(cli, desthost, pdest_ip) || !cli_session_request(cli, &calling, &smbservername)) { - DEBUG(0,("attempt_netbios_session_request: %s rejected the session for name *SMBSERVER.\n", - desthost)); + 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; } -- cgit