Btrfs: avoid buffer overrun in mount option handling
authorJim Meyering <meyering@redhat.com>
Wed, 25 Apr 2012 19:24:17 +0000 (21:24 +0200)
committerJosef Bacik <josef@redhat.com>
Wed, 30 May 2012 14:23:32 +0000 (10:23 -0400)
commitf60d16a8923201bb27ad7c09016abab2818cf8ce
tree7bb7f019dad20883b01cb7689d80195d483e37a4
parenta27202fbe92b12eec895c36644440175de01d7a6
Btrfs: avoid buffer overrun in mount option handling

There is an off-by-one error: allocating room for a maximal result
string but without room for a trailing NUL.  That, can lead to
returning a transformed string that is not NUL-terminated, and
then to a caller reading beyond end of the malloc'd buffer.

Rewrite to s/kzalloc/kmalloc/, remove unwarranted use of strncpy
(the result is guaranteed to fit), remove dead strlen at end, and
change a few variable names and comments.

Reviewed-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Jim Meyering <meyering@redhat.com>
fs/btrfs/super.c