]> git.karo-electronics.de Git - karo-tx-linux.git/commit
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)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 21 May 2011 22:13:02 +0000 (15:13 -0700)
commite025b48277c11706feb296d535b15ded500fbfdd
tree1a71fc27c1de0cbb90b5b50d815ba3af3794f59e
parent61e16b8c3e8f5657403acabbb5d4eb42e2e6b0a1
cifs: sanitize length checking in coalesce_t2 (try #3)

commit 2a2047bc94d0efc316401170c3d078d9edc20dc4 upstream.

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.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/cifs/connect.c