From: Christopher R. Hertel Date: Mon, 1 Jul 2002 03:42:04 +0000 (+0000) Subject: The 17-bit length field in the header contains the number of X-Git-Tag: samba-3.0.0alpha18~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd2b1357066a712efcf87ac61922ef871118e8de;p=thirdparty%2Fsamba.git The 17-bit length field in the header contains the number of bytes which follow the header, not the full packet size. [Yes, the length field is either 17-bits, or (per the RFCs) it is a 16-bit length field preceeded by an 8-bit flags field of which only the low-order bit may be used. If that bit is set, then add 65536 to the 16-bit length field. (In other words, it's a 17-bit unsigned length field.) ...unless, of course, the transport is native TCP [port 445] in which case the length field *might* be 24-bits wide.] Anyway, the change is a very minor one. We were including the four bytes of the header in the length count and, as a result, sending four bytes of garbage at the end of the SESSION REQUEST packet. Small fix in function cli_session_request(). --- diff --git a/source/libsmb/cliconnect.c b/source/libsmb/cliconnect.c index 50d9edf5b2d..f0b02b97b02 100644 --- a/source/libsmb/cliconnect.c +++ b/source/libsmb/cliconnect.c @@ -952,7 +952,14 @@ BOOL cli_session_request(struct cli_state *cli, name_mangle(cli->calling.name, p, cli->calling.name_type); len += name_len(p); - /* setup the packet length */ + /* setup the packet length + * Remove four bytes from the length count, since the length + * field in the NBT Session Service header counts the number + * of bytes which follow. The cli_send_smb() function knows + * about this and accounts for those four bytes. + * CRH. + */ + len -= 4; _smb_setlen(cli->outbuf,len); SCVAL(cli->outbuf,0,0x81);