summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-01-05 11:58:17 +0100
committerVolker Lendecke <vl@samba.org>2012-01-05 13:09:35 +0100
commitfed2fba0a90b8dca3bd4512281d4c53e08e59b5c (patch)
treeda51c22f345def98465f973306bdbc5abb1c3122 /source3
parentf7439f81be83be5836feb8d5050d0e9e616950b3 (diff)
downloadsamba-fed2fba0a90b8dca3bd4512281d4c53e08e59b5c.tar.gz
samba-fed2fba0a90b8dca3bd4512281d4c53e08e59b5c.tar.bz2
samba-fed2fba0a90b8dca3bd4512281d4c53e08e59b5c.zip
s3: Move basic SMB checking to a much earlier point
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/process.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index bf161bbdba..2f8f88fa2a 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -1407,25 +1407,6 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req, in
errno = 0;
- /* Make sure this is an SMB packet. smb_size contains NetBIOS header
- * so subtract 4 from it. */
- if ((size < (smb_size - 4)) || !valid_smb_header(sconn, req->inbuf)) {
- DEBUG(2,("Non-SMB packet of length %d. Terminating server\n",
- smb_len(req->inbuf)));
-
- /* special magic for immediate exit */
- if ((size == smb_size) &&
- (IVAL(req->inbuf, 4) == 0x74697865) &&
- lp_parm_bool(-1, "smbd", "suicide mode", false)) {
- uint8_t exitcode = CVAL(req->inbuf, 8);
- DEBUG(1, ("Exiting immediately with code %d\n",
- (int)exitcode));
- exit(exitcode);
- }
-
- exit_server_cleanly("Non-SMB packet");
- }
-
if (smb_messages[type].fn == NULL) {
DEBUG(0,("Unknown message type %d!\n",type));
smb_dump("Unknown", 1, (const char *)req->inbuf, size);
@@ -1667,6 +1648,25 @@ static void process_smb(struct smbd_server_connection *sconn,
}
}
+ /* Make sure this is an SMB packet. smb_size contains NetBIOS header
+ * so subtract 4 from it. */
+ if ((nread < (smb_size - 4)) || !valid_smb_header(sconn, inbuf)) {
+ DEBUG(2,("Non-SMB packet of length %d. Terminating server\n",
+ smb_len(inbuf)));
+
+ /* special magic for immediate exit */
+ if ((nread == 9) &&
+ (IVAL(inbuf, 4) == 0x74697865) &&
+ lp_parm_bool(-1, "smbd", "suicide mode", false)) {
+ uint8_t exitcode = CVAL(inbuf, 8);
+ DEBUG(1, ("Exiting immediately with code %d\n",
+ (int)exitcode));
+ exit(exitcode);
+ }
+
+ exit_server_cleanly("Non-SMB packet");
+ }
+
show_msg((char *)inbuf);
construct_reply(sconn, (char *)inbuf, nread, unread_bytes, seqnum,