fat: fix buffer overflow in vfat_create_shortname()
authorNikolaus Schulz <microschulz@web.de>
Wed, 31 Mar 2010 17:21:10 +0000 (02:21 +0900)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 26 Apr 2010 14:41:13 +0000 (07:41 -0700)
commit46049d384052f69e86855b5cb9948124a35d9a96
tree31058e1137a535a0c94112277dd3c4fe27c53c8c
parentaa35ec771b41f9803e14e4623540cb1b38fbbe2c
fat: fix buffer overflow in vfat_create_shortname()

commit 30d1872d9eb3663b4cf7bdebcbf5cd465674cced upstream.

When using the string representation of a random counter as part of the base
name, ensure that it is no longer than 4 bytes.

Since we are repeatedly decrementing the counter in a loop until we have found a
unique base name, the counter may wrap around zero; therefore, it is not enough
to mask its higher bits before entering the loop, this must be done inside the
loop.

[hirofumi@mail.parknet.co.jp: use snprintf()]
Signed-off-by: Nikolaus Schulz <microschulz@web.de>
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/fat/namei_vfat.c