summaryrefslogtreecommitdiff
path: root/source3/lib/util_sock.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-05-16 00:07:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:22:08 -0500
commit32106b23951e01fb17f814584ebbcc8d7288cb75 (patch)
treee14389fd1be0e7dae592d74f8c8518dd9a1b60a0 /source3/lib/util_sock.c
parent074af4b39d12312fc376e8d2f7bf84f0fd830874 (diff)
downloadsamba-32106b23951e01fb17f814584ebbcc8d7288cb75.tar.gz
samba-32106b23951e01fb17f814584ebbcc8d7288cb75.tar.bz2
samba-32106b23951e01fb17f814584ebbcc8d7288cb75.zip
r22920: Add in the UNIX capability for 24-bit readX, as discussed
with the Apple guys and Linux kernel guys. Still looking at how to do writeX as there's no recvfile(). Jeremy. (This used to be commit a53268fb2082de586e2df250d8ddfcff53379102)
Diffstat (limited to 'source3/lib/util_sock.c')
-rw-r--r--source3/lib/util_sock.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 46bb709521..8f32e47bb8 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -658,10 +658,12 @@ ssize_t read_smb_length(int fd, char *inbuf, unsigned int timeout)
BUFFER_SIZE+SAFETY_MARGIN.
The timeout is in milliseconds.
This function will return on receipt of a session keepalive packet.
+ maxlen is the max number of bytes to return, not including the 4 byte
+ length. If zero it means BUFFER_SIZE+SAFETY_MARGIN limit.
Doesn't check the MAC on signed packets.
****************************************************************************/
-BOOL receive_smb_raw(int fd, char *buffer, unsigned int timeout)
+ssize_t receive_smb_raw(int fd, char *buffer, unsigned int timeout, size_t maxlen)
{
ssize_t len,ret;
@@ -679,7 +681,7 @@ BOOL receive_smb_raw(int fd, char *buffer, unsigned int timeout)
if (smb_read_error == 0)
smb_read_error = READ_ERROR;
- return False;
+ return -1;
}
/*
@@ -699,11 +701,15 @@ BOOL receive_smb_raw(int fd, char *buffer, unsigned int timeout)
if (smb_read_error == 0)
smb_read_error = READ_ERROR;
- return False;
+ return -1;
}
}
if(len > 0) {
+ if (maxlen) {
+ len = MIN(len,maxlen);
+ }
+
if (timeout > 0) {
ret = read_socket_with_timeout(fd,buffer+4,len,len,timeout);
} else {
@@ -714,7 +720,7 @@ BOOL receive_smb_raw(int fd, char *buffer, unsigned int timeout)
if (smb_read_error == 0) {
smb_read_error = READ_ERROR;
}
- return False;
+ return -1;
}
/* not all of samba3 properly checks for packet-termination of strings. This
@@ -722,7 +728,7 @@ BOOL receive_smb_raw(int fd, char *buffer, unsigned int timeout)
SSVAL(buffer+4,len, 0);
}
- return True;
+ return len;
}
/****************************************************************************
@@ -732,7 +738,7 @@ BOOL receive_smb_raw(int fd, char *buffer, unsigned int timeout)
BOOL receive_smb(int fd, char *buffer, unsigned int timeout)
{
- if (!receive_smb_raw(fd, buffer, timeout)) {
+ if (!receive_smb_raw(fd, buffer, timeout, 0)) {
return False;
}