All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cifs: fix length checks in checkSMB
@ 2011-01-27 12:45 Jeff Layton
       [not found] ` <1296132305-21872-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff Layton @ 2011-01-27 12:45 UTC (permalink / raw)
  To: smfrench-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA

The cERROR message in checkSMB when the calculated length doesn't match
the RFC1001 length is incorrect in many cases. It always says that the
RFC1001 length is bigger than the SMB, even when it's actually the
reverse.

Fix the error message to say the reverse of what it does now and remove
the arbitrary check when an RFC1001 length is larger than the SMB.
There's no reason to reject those packets since we can just ignore the
junk that's hanging off the end.

Signed-off-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 fs/cifs/misc.c |   19 +++----------------
 1 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 72e99ec..959d629 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -467,23 +467,10 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
 			if (((4 + len) & 0xFFFF) == (clc_len & 0xFFFF))
 				return 0; /* bcc wrapped */
 		}
-		cFYI(1, "Calculated size %d vs length %d mismatch for mid %d",
+		cFYI(1, "Calculated size %u vs length %u mismatch for mid=%u",
 				clc_len, 4 + len, smb->Mid);
-		/* Windows XP can return a few bytes too much, presumably
-		an illegal pad, at the end of byte range lock responses
-		so we allow for that three byte pad, as long as actual
-		received length is as long or longer than calculated length */
-		/* We have now had to extend this more, since there is a
-		case in which it needs to be bigger still to handle a
-		malformed response to transact2 findfirst from WinXP when
-		access denied is returned and thus bcc and wct are zero
-		but server says length is 0x21 bytes too long as if the server
-		forget to reset the smb rfc1001 length when it reset the
-		wct and bcc to minimum size and drop the t2 parms and data */
-		if ((4+len > clc_len) && (len <= clc_len + 512))
-			return 0;
-		else {
-			cERROR(1, "RFC1001 size %d bigger than SMB for Mid=%d",
+		if (4+len < clc_len) {
+			cERROR(1, "RFC1001 size %d smaller than SMB for mid=%u",
 					len, smb->Mid);
 			return 1;
 		}
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-01-28 19:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-27 12:45 [PATCH] cifs: fix length checks in checkSMB Jeff Layton
     [not found] ` <1296132305-21872-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-01-27 20:41   ` Steve French
     [not found]     ` <AANLkTi=2A5VUOz7aTCm_EbeRZdD=e7tq=sd3AAPbzTiR-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-27 22:02       ` Jeff Layton
     [not found]         ` <20110127170225.03274b03-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2011-01-28  3:09           ` Steve French
     [not found]             ` <AANLkTimbuWJWAwbmCVVhFub4Y_Yg-QVXoqr96rGhqHd+-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-28 12:24               ` [PATCH] cifs: fix length checks in checkSMB (try #2) Jeff Layton
     [not found]                 ` <1296217463-4584-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-01-28 18:53                   ` Steve French
     [not found]                     ` <AANLkTimaH5hRX3HyHBrbXf-wP3ZaPQ2378-qsh7fi6Am-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-28 19:28                       ` Jeff Layton
     [not found]                         ` <20110128142821.75a369be-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2011-01-28 19:38                           ` Steve French

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.