summaryrefslogtreecommitdiff
path: root/source3/lib/util_sock.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-05-24 19:28:22 +0000
committerJeremy Allison <jra@samba.org>2001-05-24 19:28:22 +0000
commit9ff6634db923da17b0946141abf3ce7df61a0dab (patch)
tree229410ba018228a830faa7128b3dd5b0e22ba8b0 /source3/lib/util_sock.c
parent00cdd8cfa2cadb89c4502b061d9889998025ab9a (diff)
downloadsamba-9ff6634db923da17b0946141abf3ce7df61a0dab.tar.gz
samba-9ff6634db923da17b0946141abf3ce7df61a0dab.tar.bz2
samba-9ff6634db923da17b0946141abf3ce7df61a0dab.zip
Fixup the large_writex problem (a large_writex can send a full 64k of data,
we already have space for this we just need to understand the length correctly). Jeremy. (This used to be commit 19145bae720bbcc32dcab380c62a33d1f0e3eef0)
Diffstat (limited to 'source3/lib/util_sock.c')
-rw-r--r--source3/lib/util_sock.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 3269042117..b59debe929 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -642,35 +642,38 @@ ssize_t read_smb_length(int fd,char *inbuf,unsigned int timeout)
BOOL receive_smb(int fd,char *buffer, unsigned int timeout)
{
- ssize_t len,ret;
+ ssize_t len,ret;
- smb_read_error = 0;
+ smb_read_error = 0;
- memset(buffer,'\0',smb_size + 100);
+ memset(buffer,'\0',smb_size + 100);
- len = read_smb_length_return_keepalive(fd,buffer,timeout);
- if (len < 0)
- {
- DEBUG(10,("receive_smb: length < 0!\n"));
- return(False);
- }
+ len = read_smb_length_return_keepalive(fd,buffer,timeout);
+ if (len < 0) {
+ DEBUG(10,("receive_smb: length < 0!\n"));
+ return(False);
+ }
- if (len > BUFFER_SIZE) {
- DEBUG(0,("Invalid packet length! (%d bytes).\n",len));
- if (len > BUFFER_SIZE + (SAFETY_MARGIN/2))
- {
- exit(1);
- }
- }
+ /*
+ * A WRITEX with CAP_LARGE_WRITEX can be 64k worth of data plus 65 bytes
+ * of header. Don't print the error if this fits.... JRA.
+ */
- if(len > 0) {
- ret = read_socket_data(fd,buffer+4,len);
- if (ret != len) {
- smb_read_error = READ_ERROR;
- return False;
- }
- }
- return(True);
+ if (len > (BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE)) {
+ DEBUG(0,("Invalid packet length! (%d bytes).\n",len));
+ if (len > BUFFER_SIZE + (SAFETY_MARGIN/2))
+ exit(1);
+ }
+
+ if(len > 0) {
+ ret = read_socket_data(fd,buffer+4,len);
+ if (ret != len) {
+ smb_read_error = READ_ERROR;
+ return False;
+ }
+ }
+
+ return(True);
}
/****************************************************************************