From cae3620b2e8abbe35f0369a82d5461cb596475a3 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 24 Jun 1999 18:58:08 +0000 Subject: safe string error reporting functions (found a potential buffer overflow of a pstrcpy into an fstring). (This used to be commit ac0060443de800fec9042b69b299ff2e9128a31c) --- source3/rpc_client/cli_netlogon.c | 32 ++++++++++++++++++++++++-------- source3/rpc_client/cli_svcctl.c | 5 ++++- 2 files changed, 28 insertions(+), 9 deletions(-) (limited to 'source3/rpc_client') diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index e9a8582d10..d385011bac 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -571,8 +571,10 @@ to ourselves.\n", remote_machine)); } if (!cli_connect(&cli, remote_machine, &cli.dest_ip)) { + fstring errstr; + cli_safe_errstr(&cli, errstr, sizeof(errstr)); DEBUG(0,("modify_trust_password: unable to connect to SMB server on \ -machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli) )); +machine %s. Error was : %s.\n", remote_machine, errstr )); return False; } @@ -582,8 +584,10 @@ machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli) )); if (!cli_session_request(&cli, &calling, &called)) { + fstring errstr; + cli_safe_errstr(&cli, errstr, sizeof(errstr)); DEBUG(0,("modify_trust_password: machine %s rejected the session setup. \ -Error was : %s.\n", remote_machine, cli_errstr(&cli) )); +Error was : %s.\n", remote_machine, errstr )); cli_shutdown(&cli); return False; } @@ -591,8 +595,10 @@ Error was : %s.\n", remote_machine, cli_errstr(&cli) )); cli.protocol = PROTOCOL_NT1; if (!cli_negprot(&cli)) { + fstring errstr; + cli_safe_errstr(&cli, errstr, sizeof(errstr)); DEBUG(0,("modify_trust_password: machine %s rejected the negotiate protocol. \ -Error was : %s.\n", remote_machine, cli_errstr(&cli) )); +Error was : %s.\n", remote_machine, errstr )); cli_shutdown(&cli); return False; } @@ -608,8 +614,10 @@ Error was : %s.\n", remote_machine, cli_errstr(&cli) )); */ if (!cli_session_setup(&cli, "", "", 0, "", 0, "")) { + fstring errstr; + cli_safe_errstr(&cli, errstr, sizeof(errstr)); DEBUG(0,("modify_trust_password: machine %s rejected the session setup. \ -Error was : %s.\n", remote_machine, cli_errstr(&cli) )); +Error was : %s.\n", remote_machine, errstr )); cli_shutdown(&cli); return False; } @@ -622,8 +630,10 @@ Error was : %s.\n", remote_machine, cli_errstr(&cli) )); } if (!cli_send_tconX(&cli, "IPC$", "IPC", "", 1)) { + fstring errstr; + cli_safe_errstr(&cli, errstr, sizeof(errstr)); DEBUG(0,("modify_trust_password: machine %s rejected the tconX on the IPC$ share. \ -Error was : %s.\n", remote_machine, cli_errstr(&cli) )); +Error was : %s.\n", remote_machine, errstr )); cli_shutdown(&cli); return False; } @@ -634,8 +644,10 @@ Error was : %s.\n", remote_machine, cli_errstr(&cli) )); */ if(cli_nt_session_open(&cli, PIPE_NETLOGON, &nt_pipe_fnum) == False) { + fstring errstr; + cli_safe_errstr(&cli, errstr, sizeof(errstr)); DEBUG(0,("modify_trust_password: unable to open the domain client session to \ -machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli))); +machine %s. Error was : %s.\n", remote_machine, errstr )); cli_nt_session_close(&cli, nt_pipe_fnum); cli_ulogoff(&cli); cli_shutdown(&cli); @@ -644,8 +656,10 @@ machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli))); if(cli_nt_setup_creds(&cli, nt_pipe_fnum, cli.mach_acct, orig_trust_passwd_hash, sec_chan) == False) { + fstring errstr; + cli_safe_errstr(&cli, errstr, sizeof(errstr)); DEBUG(0,("modify_trust_password: unable to setup the PDC credentials to machine \ -%s. Error was : %s.\n", remote_machine, cli_errstr(&cli))); +%s. Error was : %s.\n", remote_machine, errstr )); cli_nt_session_close(&cli, nt_pipe_fnum); cli_ulogoff(&cli); cli_shutdown(&cli); @@ -653,9 +667,11 @@ machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli))); } if( cli_nt_srv_pwset( &cli, nt_pipe_fnum, new_trust_passwd_hash, sec_chan ) == False) { + fstring errstr; + cli_safe_errstr(&cli, errstr, sizeof(errstr)); DEBUG(0,("modify_trust_password: unable to change password for machine %s in domain \ %s to Domain controller %s. Error was %s.\n", global_myname, domain, remote_machine, - cli_errstr(&cli))); + errstr )); cli_nt_session_close(&cli, nt_pipe_fnum); cli_ulogoff(&cli); cli_shutdown(&cli); diff --git a/source3/rpc_client/cli_svcctl.c b/source3/rpc_client/cli_svcctl.c index ebf8c15dc4..5e8a3952a5 100644 --- a/source3/rpc_client/cli_svcctl.c +++ b/source3/rpc_client/cli_svcctl.c @@ -199,8 +199,11 @@ BOOL svc_enum_svcs(struct cli_state *cli, uint16 fnum, if (p && r_o.dos_status != 0) { + fstring errmsg; + smb_safe_err_msg(ERRDOS, r_o.dos_status, + errmsg, sizeof(errmsg)); /* report error code */ - DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", smb_err_msg(ERRDOS, r_o.dos_status))); + DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", errmsg)); p = r_o.dos_status == ERRmoredata; } -- cgit