From 858e63cab3b6a23692678d6eb03f9e48c3c08603 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 25 Apr 2000 14:04:06 +0000 Subject: split clientgen.c into several parts the next step is splitting out the auth code, to make adding lukes NTLMSSP support easier (This used to be commit 10c5470835b43116ed48b3137c3b9cc867a20989) --- source3/libsmb/climessage.c | 122 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 source3/libsmb/climessage.c (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c new file mode 100644 index 0000000000..c15fdbce8c --- /dev/null +++ b/source3/libsmb/climessage.c @@ -0,0 +1,122 @@ +/* + Unix SMB/Netbios implementation. + Version 3.0 + client message handling routines + Copyright (C) Andrew Tridgell 1994-1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#define NO_SYSLOG + +#include "includes.h" + + +/**************************************************************************** +start a message sequence +****************************************************************************/ +BOOL cli_message_start(struct cli_state *cli, char *host, char *username, + int *grp) +{ + char *p; + + /* send a SMBsendstrt command */ + memset(cli->outbuf,'\0',smb_size); + set_message(cli->outbuf,0,0,True); + CVAL(cli->outbuf,smb_com) = SMBsendstrt; + SSVAL(cli->outbuf,smb_tid,cli->cnum); + cli_setup_packet(cli); + + p = smb_buf(cli->outbuf); + *p++ = 4; + pstrcpy(p,username); + unix_to_dos(p,True); + p = skip_string(p,1); + *p++ = 4; + pstrcpy(p,host); + unix_to_dos(p,True); + p = skip_string(p,1); + + set_message(cli->outbuf,0,PTR_DIFF(p,smb_buf(cli->outbuf)),False); + + cli_send_smb(cli); + + if (!cli_receive_smb(cli)) { + return False; + } + + if (cli_error(cli, NULL, NULL, NULL)) return False; + + *grp = SVAL(cli->inbuf,smb_vwv0); + + return True; +} + + +/**************************************************************************** +send a message +****************************************************************************/ +BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) +{ + char *p; + + memset(cli->outbuf,'\0',smb_size); + set_message(cli->outbuf,1,len+3,True); + CVAL(cli->outbuf,smb_com) = SMBsendtxt; + SSVAL(cli->outbuf,smb_tid,cli->cnum); + cli_setup_packet(cli); + + SSVAL(cli->outbuf,smb_vwv0,grp); + + p = smb_buf(cli->outbuf); + *p = 1; + SSVAL(p,1,len); + memcpy(p+3,msg,len); + cli_send_smb(cli); + + if (!cli_receive_smb(cli)) { + return False; + } + + if (cli_error(cli, NULL, NULL, NULL)) return False; + + return True; +} + +/**************************************************************************** +end a message +****************************************************************************/ +BOOL cli_message_end(struct cli_state *cli, int grp) +{ + memset(cli->outbuf,'\0',smb_size); + set_message(cli->outbuf,1,0,True); + CVAL(cli->outbuf,smb_com) = SMBsendend; + SSVAL(cli->outbuf,smb_tid,cli->cnum); + + SSVAL(cli->outbuf,smb_vwv0,grp); + + cli_setup_packet(cli); + + cli_send_smb(cli); + + if (!cli_receive_smb(cli)) { + return False; + } + + if (cli_error(cli, NULL, NULL, NULL)) return False; + + return True; +} + -- cgit From 8acf5e04482cb43734fbb786f8d363ee3bfff652 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 20 Feb 2001 12:45:50 +0000 Subject: - neater setting of bcc - converted cli_rename and cli_unlink (This used to be commit 0a8992e224b7a3d90d45b13d73fa8a6f155efa79) --- source3/libsmb/climessage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index c15fdbce8c..058358e2f1 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -49,7 +49,7 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, unix_to_dos(p,True); p = skip_string(p,1); - set_message(cli->outbuf,0,PTR_DIFF(p,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, p); cli_send_smb(cli); -- cgit From 064898cf8ad604c3d0a7399964b122d4c53fe7df Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 20 Feb 2001 13:16:01 +0000 Subject: converted a bunch more fns (This used to be commit f6b8d6730452522f77852af0917cb48424d4c8a9) --- source3/libsmb/climessage.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 058358e2f1..47139dcfd6 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -41,13 +41,11 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, p = smb_buf(cli->outbuf); *p++ = 4; - pstrcpy(p,username); - unix_to_dos(p,True); - p = skip_string(p,1); + p += clistr_push(cli, p, username, -1, + CLISTR_TERMINATE|CLISTR_CONVERT); *p++ = 4; - pstrcpy(p,host); - unix_to_dos(p,True); - p = skip_string(p,1); + p += clistr_push(cli, p, host, -1, + CLISTR_TERMINATE|CLISTR_CONVERT); cli_setup_bcc(cli, p); -- cgit From 45c2ee3ff2d01fdd0a2db9fa90457cff4663c43d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 10 Mar 2001 11:35:25 +0000 Subject: to use the same macros in the client and server rename the CLISTR_ macros to STR_ (This used to be commit 95c9e4e0ba8f37f565aaf136f41eb76489441ff7) --- source3/libsmb/climessage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 47139dcfd6..87f8175459 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -42,10 +42,10 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, p = smb_buf(cli->outbuf); *p++ = 4; p += clistr_push(cli, p, username, -1, - CLISTR_TERMINATE|CLISTR_CONVERT); + STR_TERMINATE|STR_CONVERT); *p++ = 4; p += clistr_push(cli, p, host, -1, - CLISTR_TERMINATE|CLISTR_CONVERT); + STR_TERMINATE|STR_CONVERT); cli_setup_bcc(cli, p); -- cgit From 4ff011d88ef5b79b92d2cea1abe32c93bc03f724 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 21 Jun 2001 05:38:28 +0000 Subject: Added STR_NOALIGN flags to clistr and srvstr fns. Yes, NT actually does send unaligned unicode strings sometimes! Fixed our handling of the workgroup name tacked on the end of the NT1 negprot response (a unaligned unicode) fixed a couple of places where we should be using the message_end fns instead of pre-calculated buffer lengths (This used to be commit 86613493a9b2e56523153486931d0bf8d39beb7a) --- source3/libsmb/climessage.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 87f8175459..d46986bfd6 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -71,7 +71,7 @@ BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) char *p; memset(cli->outbuf,'\0',smb_size); - set_message(cli->outbuf,1,len+3,True); + set_message(cli->outbuf,1,0,True); CVAL(cli->outbuf,smb_com) = SMBsendtxt; SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); @@ -79,9 +79,12 @@ BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) SSVAL(cli->outbuf,smb_vwv0,grp); p = smb_buf(cli->outbuf); - *p = 1; - SSVAL(p,1,len); - memcpy(p+3,msg,len); + *p++ = 1; + SSVAL(p,0,len); p += 2; + memcpy(p,msg,len); + p += len; + + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { -- cgit From 87fbb7092b8f8b2f0db0f361c3d625e19de57cd9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:15:53 +0000 Subject: The big character set handling changeover! This commit gets rid of all our old codepage handling and replaces it with iconv. All internal strings in Samba are now in "unix" charset, which may be multi-byte. See internals.doc and my posting to samba-technical for a more complete explanation. (This used to be commit debb471267960e56005a741817ebd227ecfc512a) --- source3/libsmb/climessage.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index d46986bfd6..e0a308104b 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -41,11 +41,9 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, p = smb_buf(cli->outbuf); *p++ = 4; - p += clistr_push(cli, p, username, -1, - STR_TERMINATE|STR_CONVERT); + p += clistr_push(cli, p, username, -1, STR_TERMINATE); *p++ = 4; - p += clistr_push(cli, p, host, -1, - STR_TERMINATE|STR_CONVERT); + p += clistr_push(cli, p, host, -1, STR_TERMINATE); cli_setup_bcc(cli, p); -- cgit From 2ccfea3de7b2b7dc0be2438c3adb3f7be82a2dfc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 10 Aug 2001 06:00:33 +0000 Subject: A rewrite of the error handling in the libsmb client code. I've separated out the error handling into a bunch of separate functions rather than all being handled in one big function. Fetch error codes from the last received packet: void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *num); uint32 cli_nt_error(struct cli_state *); Convert errors to UNIX errno values: int cli_errno_from_dos(uint8 eclass, uint32 num); int cli_errno_from_nt(uint32 status); int cli_errno(struct cli_state *cli); Detect different kinds of errors: BOOL cli_is_dos_error(struct cli_state *cli); BOOL cli_is_nt_error(struct cli_state *cli); BOOL cli_is_error(struct cli_state *cli); This also means we now support CAP_STATUS32 as we can decode and understand NT errors instead of just DOS errors. Yay! Ported a whole bunch of files in libsmb to use this new API instead of the just the DOS error. (This used to be commit 6dbdb0d813f3c7ab20b38baa1223b0b479aadec9) --- source3/libsmb/climessage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index e0a308104b..d32c5de042 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -53,7 +53,7 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, return False; } - if (cli_error(cli, NULL, NULL, NULL)) return False; + if (cli_is_error(cli)) return False; *grp = SVAL(cli->inbuf,smb_vwv0); @@ -89,7 +89,7 @@ BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) return False; } - if (cli_error(cli, NULL, NULL, NULL)) return False; + if (cli_is_error(cli)) return False; return True; } @@ -114,7 +114,7 @@ BOOL cli_message_end(struct cli_state *cli, int grp) return False; } - if (cli_error(cli, NULL, NULL, NULL)) return False; + if (cli_is_error(cli)) return False; return True; } -- cgit From d6823366b881612234ab0655adb11c594f864c4a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 11 Jan 2002 19:10:25 +0000 Subject: Same fix as went into 2.2 (I'm waiting for jerry to finish some code). Jeremy. (This used to be commit 01ff6ce4963e1daff019f2b936cef218e1c93f67) --- source3/libsmb/climessage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index d32c5de042..5ded79de96 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -35,7 +35,7 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, /* send a SMBsendstrt command */ memset(cli->outbuf,'\0',smb_size); set_message(cli->outbuf,0,0,True); - CVAL(cli->outbuf,smb_com) = SMBsendstrt; + SCVAL(cli->outbuf,smb_com,SMBsendstrt); SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); @@ -70,7 +70,7 @@ BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) memset(cli->outbuf,'\0',smb_size); set_message(cli->outbuf,1,0,True); - CVAL(cli->outbuf,smb_com) = SMBsendtxt; + SCVAL(cli->outbuf,smb_com,SMBsendtxt); SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); @@ -101,7 +101,7 @@ BOOL cli_message_end(struct cli_state *cli, int grp) { memset(cli->outbuf,'\0',smb_size); set_message(cli->outbuf,1,0,True); - CVAL(cli->outbuf,smb_com) = SMBsendend; + SCVAL(cli->outbuf,smb_com,SMBsendend); SSVAL(cli->outbuf,smb_tid,cli->cnum); SSVAL(cli->outbuf,smb_vwv0,grp); -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/libsmb/climessage.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 5ded79de96..1587e6f4cd 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 3.0 + Unix SMB/CIFS implementation. client message handling routines Copyright (C) Andrew Tridgell 1994-1998 -- cgit From 0b72dd8325bc5c78de56039942acc175d28042a7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Mar 2003 16:44:14 +0000 Subject: Patch from Samuel Thibault to convert messages from dos to unix charset when sending(and vice versa when receiving). (This used to be commit 5310447ec6e0df1c000e3ee14572f5b7fee31f28) --- source3/libsmb/climessage.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 1587e6f4cd..5f6ce36133 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -65,6 +65,8 @@ send a message ****************************************************************************/ BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) { + char *msgdos; + int lendos; char *p; memset(cli->outbuf,'\0',smb_size); @@ -77,9 +79,18 @@ BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) p = smb_buf(cli->outbuf); *p++ = 1; - SSVAL(p,0,len); p += 2; - memcpy(p,msg,len); - p += len; + + if ((lendos = convert_string_allocate(CH_UNIX, CH_DOS, msg,len, (void **) &msgdos)) < 0 || !msgdos) { + DEBUG(3,("Conversion failed, sending message in UNIX charset\n")); + SSVAL(p, 0, len); p += 2; + memcpy(p, msg, len); + p += len; + } else { + SSVAL(p, 0, lendos); p += 2; + memcpy(p, msgdos, lendos); + p += lendos; + SAFE_FREE(msgdos); + } cli_setup_bcc(cli, p); cli_send_smb(cli); -- cgit From 1af398b16913b9ae66ac66c4f65134dc4c8fb195 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 7 May 2003 02:00:58 +0000 Subject: Force ASCII for client messages. Patch from David Lee Jeremy. (This used to be commit f219e8309c7d17b332873e9283ab3c3796e7e799) --- source3/libsmb/climessage.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 5f6ce36133..2b1be75089 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -40,9 +40,9 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, p = smb_buf(cli->outbuf); *p++ = 4; - p += clistr_push(cli, p, username, -1, STR_TERMINATE); + p += clistr_push(cli, p, username, -1, STR_ASCII|STR_TERMINATE); *p++ = 4; - p += clistr_push(cli, p, host, -1, STR_TERMINATE); + p += clistr_push(cli, p, host, -1, STR_ASCII|STR_TERMINATE); cli_setup_bcc(cli, p); @@ -128,4 +128,3 @@ BOOL cli_message_end(struct cli_state *cli, int grp) return True; } - -- cgit From babab82d9a7f9de5409c8f53b0d66b7f8ffefd94 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 6 Jun 2003 23:09:39 +0000 Subject: applying David Lee's climessage patch to make sending messages more extendable (This used to be commit a5240adc4944342529702542e080c378d3883a09) --- source3/libsmb/climessage.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 2b1be75089..8ce8416487 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -26,12 +26,11 @@ /**************************************************************************** start a message sequence ****************************************************************************/ -BOOL cli_message_start(struct cli_state *cli, char *host, char *username, - int *grp) +int cli_message_start_build(struct cli_state *cli, char *host, char *username) { char *p; - /* send a SMBsendstrt command */ + /* construct a SMBsendstrt command */ memset(cli->outbuf,'\0',smb_size); set_message(cli->outbuf,0,0,True); SCVAL(cli->outbuf,smb_com,SMBsendstrt); @@ -45,6 +44,14 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, p += clistr_push(cli, p, host, -1, STR_ASCII|STR_TERMINATE); cli_setup_bcc(cli, p); + + return(PTR_DIFF(p, cli->outbuf)); +} + +BOOL cli_message_start(struct cli_state *cli, char *host, char *username, + int *grp) +{ + cli_message_start_build(cli, host, username); cli_send_smb(cli); @@ -63,7 +70,7 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, /**************************************************************************** send a message ****************************************************************************/ -BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) +int cli_message_text_build(struct cli_state *cli, char *msg, int len, int grp) { char *msgdos; int lendos; @@ -93,6 +100,14 @@ BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) } cli_setup_bcc(cli, p); + + return(PTR_DIFF(p, cli->outbuf)); +} + +BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) +{ + cli_message_text_build(cli, msg, len, grp); + cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -107,8 +122,10 @@ BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) /**************************************************************************** end a message ****************************************************************************/ -BOOL cli_message_end(struct cli_state *cli, int grp) +int cli_message_end_build(struct cli_state *cli, int grp) { + char *p; + memset(cli->outbuf,'\0',smb_size); set_message(cli->outbuf,1,0,True); SCVAL(cli->outbuf,smb_com,SMBsendend); @@ -117,7 +134,16 @@ BOOL cli_message_end(struct cli_state *cli, int grp) SSVAL(cli->outbuf,smb_vwv0,grp); cli_setup_packet(cli); - + + p = smb_buf(cli->outbuf); + + return(PTR_DIFF(p, cli->outbuf)); +} + +BOOL cli_message_end(struct cli_state *cli, int grp) +{ + cli_message_end_build(cli, grp); + cli_send_smb(cli); if (!cli_receive_smb(cli)) { -- cgit From ecddae8bf012c6b9dc4e99c788c14adde64baba8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 20 Aug 2003 22:06:19 +0000 Subject: Attempt to fix the charcnv issues causing nmbd to crash. If we get a failed conversion simply copy as is. Also fixed the horrid malloc-twice-copy code in the convert alloc path. Jeremy. (This used to be commit cfde7477fd12caef943a9422b52174438092a135) --- source3/libsmb/climessage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 8ce8416487..035088212c 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -87,7 +87,7 @@ int cli_message_text_build(struct cli_state *cli, char *msg, int len, int grp) p = smb_buf(cli->outbuf); *p++ = 1; - if ((lendos = convert_string_allocate(CH_UNIX, CH_DOS, msg,len, (void **) &msgdos)) < 0 || !msgdos) { + if ((lendos = convert_string_allocate(NULL,CH_UNIX, CH_DOS, msg,len, (void **) &msgdos)) < 0 || !msgdos) { DEBUG(3,("Conversion failed, sending message in UNIX charset\n")); SSVAL(p, 0, len); p += 2; memcpy(p, msg, len); -- cgit From e3f5b542707e2328030b9d5eff0836a904eccde5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 11 Mar 2004 22:48:24 +0000 Subject: Restore the contract on all convert_stringXX() interfaces. Add a "allow_bad_conv" boolean parameter that allows broken iconv conversions to work. Gets rid of the nasty errno checks in mangle_hash2 and check_path_syntax and allows correct return code checking. Jeremy. (This used to be commit 7b96765c23637613f079d37566d95d5edd511f05) --- source3/libsmb/climessage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 035088212c..8429ca4f41 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -87,7 +87,7 @@ int cli_message_text_build(struct cli_state *cli, char *msg, int len, int grp) p = smb_buf(cli->outbuf); *p++ = 1; - if ((lendos = convert_string_allocate(NULL,CH_UNIX, CH_DOS, msg,len, (void **) &msgdos)) < 0 || !msgdos) { + if ((lendos = (int)convert_string_allocate(NULL,CH_UNIX, CH_DOS, msg,len, (void **) &msgdos, True)) < 0 || !msgdos) { DEBUG(3,("Conversion failed, sending message in UNIX charset\n")); SSVAL(p, 0, len); p += 2; memcpy(p, msg, len); -- cgit From ab398643a4e44211696ef5ce72b62ab7ecee7bc9 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 19 Jul 2005 02:37:04 +0000 Subject: r8572: Remove crufty #define NO_SYSLOG as it's not used at all anymore. (This used to be commit 985dbb47d925e79c1195ca219f7ab5d6648b22b8) --- source3/libsmb/climessage.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 8429ca4f41..f646096a4e 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -18,8 +18,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define NO_SYSLOG - #include "includes.h" -- cgit From d1f91f7c723733113b4e9792042101c80dfc064c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Dec 2005 06:46:46 +0000 Subject: r12043: It's amazing the warnings you find when compiling on a 64-bit box with gcc4 and -O6... Fix a bunch of C99 dereferencing type-punned pointer will break strict-aliasing rules errors. Also added prs_int32 (not uint32...) as it's needed in one place. Find places where prs_uint32 was being used to marshall/unmarshall a time_t (a big no no on 64-bits). More warning fixes to come. Thanks to Volker for nudging me to compile like this. Jeremy. (This used to be commit c65b752604f8f58abc4e7ae8514dc2c7f086271c) --- source3/libsmb/climessage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index f646096a4e..1aa659c1ba 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -85,7 +85,7 @@ int cli_message_text_build(struct cli_state *cli, char *msg, int len, int grp) p = smb_buf(cli->outbuf); *p++ = 1; - if ((lendos = (int)convert_string_allocate(NULL,CH_UNIX, CH_DOS, msg,len, (void **) &msgdos, True)) < 0 || !msgdos) { + if ((lendos = (int)convert_string_allocate(NULL,CH_UNIX, CH_DOS, msg,len, (void **)(void *)&msgdos, True)) < 0 || !msgdos) { DEBUG(3,("Conversion failed, sending message in UNIX charset\n")); SSVAL(p, 0, len); p += 2; memcpy(p, msg, len); -- cgit From 0829e1ad1c3646efecf50729f493b9ee72ef0517 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 19 Apr 2007 22:40:32 +0000 Subject: r22391: Looks bigger than it is. Make "inbuf" available to all callers of smb_setlen (via set_message() calls). This will allow the server to reflect back the correct encryption context. Jeremy. (This used to be commit 2d80a96120a5fe2fe726f00746d36d85044c4bdb) --- source3/libsmb/climessage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 1aa659c1ba..6850c4b8df 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -30,7 +30,7 @@ int cli_message_start_build(struct cli_state *cli, char *host, char *username) /* construct a SMBsendstrt command */ memset(cli->outbuf,'\0',smb_size); - set_message(cli->outbuf,0,0,True); + set_message(NULL,cli->outbuf,0,0,True); SCVAL(cli->outbuf,smb_com,SMBsendstrt); SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); @@ -75,7 +75,7 @@ int cli_message_text_build(struct cli_state *cli, char *msg, int len, int grp) char *p; memset(cli->outbuf,'\0',smb_size); - set_message(cli->outbuf,1,0,True); + set_message(NULL,cli->outbuf,1,0,True); SCVAL(cli->outbuf,smb_com,SMBsendtxt); SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); @@ -125,7 +125,7 @@ int cli_message_end_build(struct cli_state *cli, int grp) char *p; memset(cli->outbuf,'\0',smb_size); - set_message(cli->outbuf,1,0,True); + set_message(NULL,cli->outbuf,1,0,True); SCVAL(cli->outbuf,smb_com,SMBsendend); SSVAL(cli->outbuf,smb_tid,cli->cnum); -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/libsmb/climessage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 6850c4b8df..e0685958d4 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/libsmb/climessage.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index e0685958d4..252f2cd725 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From e5a951325a6cac8567af3a66de6d2df577508ae4 Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Wed, 10 Oct 2007 15:34:30 -0500 Subject: [GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch. (This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab) --- source3/libsmb/climessage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 252f2cd725..46d7c1c3be 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -29,7 +29,7 @@ int cli_message_start_build(struct cli_state *cli, char *host, char *username) /* construct a SMBsendstrt command */ memset(cli->outbuf,'\0',smb_size); - set_message(NULL,cli->outbuf,0,0,True); + set_message(cli->outbuf,0,0,True); SCVAL(cli->outbuf,smb_com,SMBsendstrt); SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); @@ -74,7 +74,7 @@ int cli_message_text_build(struct cli_state *cli, char *msg, int len, int grp) char *p; memset(cli->outbuf,'\0',smb_size); - set_message(NULL,cli->outbuf,1,0,True); + set_message(cli->outbuf,1,0,True); SCVAL(cli->outbuf,smb_com,SMBsendtxt); SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); @@ -124,7 +124,7 @@ int cli_message_end_build(struct cli_state *cli, int grp) char *p; memset(cli->outbuf,'\0',smb_size); - set_message(NULL,cli->outbuf,1,0,True); + set_message(cli->outbuf,1,0,True); SCVAL(cli->outbuf,smb_com,SMBsendend); SSVAL(cli->outbuf,smb_tid,cli->cnum); -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/libsmb/climessage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 46d7c1c3be..2a195753ae 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -45,7 +45,7 @@ int cli_message_start_build(struct cli_state *cli, char *host, char *username) return(PTR_DIFF(p, cli->outbuf)); } -BOOL cli_message_start(struct cli_state *cli, char *host, char *username, +bool cli_message_start(struct cli_state *cli, char *host, char *username, int *grp) { cli_message_start_build(cli, host, username); @@ -101,7 +101,7 @@ int cli_message_text_build(struct cli_state *cli, char *msg, int len, int grp) return(PTR_DIFF(p, cli->outbuf)); } -BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) +bool cli_message_text(struct cli_state *cli, char *msg, int len, int grp) { cli_message_text_build(cli, msg, len, grp); @@ -137,7 +137,7 @@ int cli_message_end_build(struct cli_state *cli, int grp) return(PTR_DIFF(p, cli->outbuf)); } -BOOL cli_message_end(struct cli_state *cli, int grp) +bool cli_message_end(struct cli_state *cli, int grp) { cli_message_end_build(cli, grp); -- cgit From 1b92ea5559bfa00016103508feac9a06ea4b66ae Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 6 Dec 2007 17:16:33 -0800 Subject: Remove pstrings from client/client.c by doing a large rewrite. Mostly compiles.... Jeremy. (This used to be commit c87f3eba9aa52f4ab25d77e2167262bf5c43b1a6) --- source3/libsmb/climessage.c | 46 ++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 2a195753ae..13ef1d43d4 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -19,11 +19,11 @@ #include "includes.h" - /**************************************************************************** -start a message sequence + Start a message sequence. ****************************************************************************/ -int cli_message_start_build(struct cli_state *cli, char *host, char *username) + +int cli_message_start_build(struct cli_state *cli, const char *host, const char *username) { char *p; @@ -33,25 +33,26 @@ int cli_message_start_build(struct cli_state *cli, char *host, char *username) SCVAL(cli->outbuf,smb_com,SMBsendstrt); SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); - + p = smb_buf(cli->outbuf); *p++ = 4; - p += clistr_push(cli, p, username, -1, STR_ASCII|STR_TERMINATE); + p += clistr_push(cli, p, username, + cli->bufsize - PTR_DIFF(p,cli->outbuf), STR_ASCII|STR_TERMINATE); *p++ = 4; - p += clistr_push(cli, p, host, -1, STR_ASCII|STR_TERMINATE); - + p += clistr_push(cli, p, host, + cli->bufsize - PTR_DIFF(p,cli->outbuf), STR_ASCII|STR_TERMINATE); + cli_setup_bcc(cli, p); return(PTR_DIFF(p, cli->outbuf)); } -bool cli_message_start(struct cli_state *cli, char *host, char *username, +bool cli_message_start(struct cli_state *cli, const char *host, const char *username, int *grp) { cli_message_start_build(cli, host, username); - - cli_send_smb(cli); - + cli_send_smb(cli); + if (!cli_receive_smb(cli)) { return False; } @@ -63,11 +64,11 @@ bool cli_message_start(struct cli_state *cli, char *host, char *username, return True; } - /**************************************************************************** -send a message + Send a message ****************************************************************************/ -int cli_message_text_build(struct cli_state *cli, char *msg, int len, int grp) + +int cli_message_text_build(struct cli_state *cli, const char *msg, int len, int grp) { char *msgdos; int lendos; @@ -80,17 +81,23 @@ int cli_message_text_build(struct cli_state *cli, char *msg, int len, int grp) cli_setup_packet(cli); SSVAL(cli->outbuf,smb_vwv0,grp); - + p = smb_buf(cli->outbuf); *p++ = 1; if ((lendos = (int)convert_string_allocate(NULL,CH_UNIX, CH_DOS, msg,len, (void **)(void *)&msgdos, True)) < 0 || !msgdos) { DEBUG(3,("Conversion failed, sending message in UNIX charset\n")); SSVAL(p, 0, len); p += 2; + if (len > cli->bufsize - PTR_DIFF(p,cli->outbuf)) { + return -1; + } memcpy(p, msg, len); p += len; } else { SSVAL(p, 0, lendos); p += 2; + if (lendos > cli->bufsize - PTR_DIFF(p,cli->outbuf)) { + return -1; + } memcpy(p, msgdos, lendos); p += lendos; SAFE_FREE(msgdos); @@ -101,7 +108,7 @@ int cli_message_text_build(struct cli_state *cli, char *msg, int len, int grp) return(PTR_DIFF(p, cli->outbuf)); } -bool cli_message_text(struct cli_state *cli, char *msg, int len, int grp) +bool cli_message_text(struct cli_state *cli, const char *msg, int len, int grp) { cli_message_text_build(cli, msg, len, grp); @@ -114,11 +121,12 @@ bool cli_message_text(struct cli_state *cli, char *msg, int len, int grp) if (cli_is_error(cli)) return False; return True; -} +} /**************************************************************************** -end a message + End a message. ****************************************************************************/ + int cli_message_end_build(struct cli_state *cli, int grp) { char *p; @@ -150,4 +158,4 @@ bool cli_message_end(struct cli_state *cli, int grp) if (cli_is_error(cli)) return False; return True; -} +} -- cgit From afc93255d183eefb68e45b8ec6275f6a62cf9795 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 26 Dec 2007 17:12:36 -0800 Subject: Add SMB encryption. Still fixing client decrypt but negotiation works. Jeremy. (This used to be commit d78045601af787731f0737b8627450018902b104) --- source3/libsmb/climessage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 13ef1d43d4..00c25aa725 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -29,7 +29,7 @@ int cli_message_start_build(struct cli_state *cli, const char *host, const char /* construct a SMBsendstrt command */ memset(cli->outbuf,'\0',smb_size); - set_message(cli->outbuf,0,0,True); + cli_set_message(cli->outbuf,0,0,True); SCVAL(cli->outbuf,smb_com,SMBsendstrt); SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); @@ -75,7 +75,7 @@ int cli_message_text_build(struct cli_state *cli, const char *msg, int len, int char *p; memset(cli->outbuf,'\0',smb_size); - set_message(cli->outbuf,1,0,True); + cli_set_message(cli->outbuf,1,0,True); SCVAL(cli->outbuf,smb_com,SMBsendtxt); SSVAL(cli->outbuf,smb_tid,cli->cnum); cli_setup_packet(cli); @@ -132,7 +132,7 @@ int cli_message_end_build(struct cli_state *cli, int grp) char *p; memset(cli->outbuf,'\0',smb_size); - set_message(cli->outbuf,1,0,True); + cli_set_message(cli->outbuf,1,0,True); SCVAL(cli->outbuf,smb_com,SMBsendend); SSVAL(cli->outbuf,smb_tid,cli->cnum); -- cgit From bb869741ddc3d82da02c96bef592dab6074ff142 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Mon, 3 Mar 2008 13:32:54 -0800 Subject: Cleanup size_t return values in convert_string_allocate This patch is the first iteration of an inside-out conversion to cleanup functions in charcnv.c returning size_t == -1 to indicate failure. (This used to be commit 59124382d2894a1b194b48dd82bc5f956959eb48) --- source3/libsmb/climessage.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/libsmb/climessage.c') diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 00c25aa725..808190e79c 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -71,7 +71,7 @@ bool cli_message_start(struct cli_state *cli, const char *host, const char *user int cli_message_text_build(struct cli_state *cli, const char *msg, int len, int grp) { char *msgdos; - int lendos; + size_t lendos; char *p; memset(cli->outbuf,'\0',smb_size); @@ -85,7 +85,8 @@ int cli_message_text_build(struct cli_state *cli, const char *msg, int len, int p = smb_buf(cli->outbuf); *p++ = 1; - if ((lendos = (int)convert_string_allocate(NULL,CH_UNIX, CH_DOS, msg,len, (void **)(void *)&msgdos, True)) < 0 || !msgdos) { + if (!convert_string_allocate(NULL, CH_UNIX, CH_DOS, msg, len, + (void **)(void *)&msgdos, &lendos, True) || !msgdos) { DEBUG(3,("Conversion failed, sending message in UNIX charset\n")); SSVAL(p, 0, len); p += 2; if (len > cli->bufsize - PTR_DIFF(p,cli->outbuf)) { -- cgit