cifs: sanitize length checking in coalesce_t2 (try #3)
authorJeff Layton <jlayton@redhat.com>
Wed, 27 Apr 2011 17:29:49 +0000 (13:29 -0400)
committerSteve French <sfrench@us.ibm.com>
Fri, 29 Apr 2011 05:02:08 +0000 (05:02 +0000)
commit2a2047bc94d0efc316401170c3d078d9edc20dc4
treefb085ee1125e6f754c817df84cc603e56d664c52
parentfcda7f4578bbf9717444ca6da8a421d21489d078
cifs: sanitize length checking in coalesce_t2 (try #3)

There are a couple of places in this code where these values can wrap or
go negative, and that could potentially end up overflowing the buffer.
Ensure that that doesn't happen. Do all of the length calculation and
checks first, and only perform the memcpy after they pass.

Also, increase some stack variables to 32 bits to ensure that they don't
wrap without being detected.

Finally, change the error codes to be a bit more descriptive of any
problems detected. -EINVAL isn't very accurate.

Cc: stable@kernel.org
Reported-and-Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/connect.c