summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1996-06-10 05:16:19 +0000
committerAndrew Tridgell <tridge@samba.org>1996-06-10 05:16:19 +0000
commita521fe8a274c8a043cf77641dd4160fdef803533 (patch)
tree67bbb5bb827896e10f7e611d02a8e5710a9045fe /source3/lib
parent7e3b4a1c0df1434eb3d02f93c736ce065f9898d8 (diff)
downloadsamba-a521fe8a274c8a043cf77641dd4160fdef803533.tar.gz
samba-a521fe8a274c8a043cf77641dd4160fdef803533.tar.bz2
samba-a521fe8a274c8a043cf77641dd4160fdef803533.zip
a cleanup of the receive_smb() usage, adding timeouts in some places
also added paranoid code in the main process() loop of smbd to detect when smbd is looping uselessly. This should stop the "smbd is chewing lots of cpu" reports (This used to be commit 8e9dce34d50d673cb50531f0c4c7672ce2522cef)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index fc47313b57..ee4fca3ed3 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2079,7 +2079,7 @@ int read_smb_length(int fd,char *inbuf,int timeout)
if (msg_type == 0x85)
{
- DEBUG(5,( "Got keepalive packet\n"));
+ DEBUG(5,("Got keepalive packet\n"));
ok = False;
}
}
@@ -2097,8 +2097,7 @@ The timeout is in milli seconds
****************************************************************************/
BOOL receive_smb(int fd,char *buffer,int timeout)
{
- int len;
- BOOL ok;
+ int len,ret;
bzero(buffer,smb_size + 100);
@@ -2107,18 +2106,16 @@ BOOL receive_smb(int fd,char *buffer,int timeout)
return(False);
if (len > BUFFER_SIZE) {
- DEBUG(0,("Invalid packet length! (%d bytes)\n",len));
+ DEBUG(0,("Invalid packet length! (%d bytes).\n",len));
if (len > BUFFER_SIZE + (SAFETY_MARGIN/2))
exit(1);
}
- ok = (read_data(fd,buffer+4,len) == len);
-
- if (!ok)
- {
- close_sockets();
- exit(1);
- }
+ ret = read_data(fd,buffer+4,len);
+ if (ret != len) {
+ DEBUG(0,("ERROR: Invalid SMB length. Expected %d got %d\n",len,ret));
+ return False;
+ }
return(True);
}