From: Jeff Layton Date: Wed, 27 Apr 2011 17:25:51 +0000 (-0400) Subject: cifs: check for bytes_remaining going to zero in CIFS_SessSetup X-Git-Tag: v2.6.33.14~22 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=0a26a86d85719e0085c25e303aa7a31ba9b47d75;p=karo-tx-linux.git cifs: check for bytes_remaining going to zero in CIFS_SessSetup commit fcda7f4578bbf9717444ca6da8a421d21489d078 upstream. It's possible that when we go to decode the string area in the SESSION_SETUP response, that bytes_remaining will be 0. Decrementing it at that point will mean that it can go "negative" and wrap. Check for a bytes_remaining value of 0, and don't try to decode the string area if that's the case. Reported-and-Acked-by: David Howells Signed-off-by: Jeff Layton Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 7ca42eb05548..2867581263bb 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c @@ -905,7 +905,9 @@ ssetup_ntlmssp_authenticate: } /* BB check if Unicode and decode strings */ - if (smb_buf->Flags2 & SMBFLG2_UNICODE) { + if (bytes_remaining == 0) { + /* no string area to decode, do nothing */ + } else if (smb_buf->Flags2 & SMBFLG2_UNICODE) { /* unicode string area must be word-aligned */ if (((unsigned long) bcc_ptr - (unsigned long) smb_buf) % 2) { ++bcc_ptr;