aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/misc.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2011-01-28 15:05:42 -0500
committerSteve French <sfrench@us.ibm.com>2011-01-30 23:30:37 -0500
commit68abaffa6bbd3cadfaa4b7216d10bcd32406090b (patch)
treebcc6daaddbf65798a6fa27451a3456c2415cd46e /fs/cifs/misc.c
parent2db7c5815555d8daabf7d4ab1253ce690852c140 (diff)
cifs: simplify SMB header check routine
...just cleanup. There should be no behavior change. Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Pavel Shilovsky <piastryyy@gmail.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/misc.c')
-rw-r--r--fs/cifs/misc.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index a09e077ba925..72e99ece78cf 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -381,29 +381,31 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
381} 381}
382 382
383static int 383static int
384checkSMBhdr(struct smb_hdr *smb, __u16 mid) 384check_smb_hdr(struct smb_hdr *smb, __u16 mid)
385{ 385{
386 /* Make sure that this really is an SMB, that it is a response, 386 /* does it have the right SMB "signature" ? */
387 and that the message ids match */ 387 if (*(__le32 *) smb->Protocol != cpu_to_le32(0x424d53ff)) {
388 if ((*(__le32 *) smb->Protocol == cpu_to_le32(0x424d53ff)) && 388 cERROR(1, "Bad protocol string signature header 0x%x",
389 (mid == smb->Mid)) { 389 *(unsigned int *)smb->Protocol);
390 if (smb->Flags & SMBFLG_RESPONSE) 390 return 1;
391 return 0;
392 else {
393 /* only one valid case where server sends us request */
394 if (smb->Command == SMB_COM_LOCKING_ANDX)
395 return 0;
396 else
397 cERROR(1, "Received Request not response");
398 }
399 } else { /* bad signature or mid */
400 if (*(__le32 *) smb->Protocol != cpu_to_le32(0x424d53ff))
401 cERROR(1, "Bad protocol string signature header %x",
402 *(unsigned int *) smb->Protocol);
403 if (mid != smb->Mid)
404 cERROR(1, "Mids do not match");
405 } 391 }
406 cERROR(1, "bad smb detected. The Mid=%d", smb->Mid); 392
393 /* Make sure that message ids match */
394 if (mid != smb->Mid) {
395 cERROR(1, "Mids do not match. received=%u expected=%u",
396 smb->Mid, mid);
397 return 1;
398 }
399
400 /* if it's a response then accept */
401 if (smb->Flags & SMBFLG_RESPONSE)
402 return 0;
403
404 /* only one valid case where server sends us request */
405 if (smb->Command == SMB_COM_LOCKING_ANDX)
406 return 0;
407
408 cERROR(1, "Server sent request, not response. mid=%u", smb->Mid);
407 return 1; 409 return 1;
408} 410}
409 411
@@ -448,7 +450,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
448 return 1; 450 return 1;
449 } 451 }
450 452
451 if (checkSMBhdr(smb, mid)) 453 if (check_smb_hdr(smb, mid))
452 return 1; 454 return 1;
453 clc_len = smbCalcSize_LE(smb); 455 clc_len = smbCalcSize_LE(smb);
454 456