fat: fix buffer overflow in vfat_create_shortname()
authorNikolaus Schulz <microschulz@web.de>
Wed, 31 Mar 2010 17:21:10 +0000 (02:21 +0900)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 31 Mar 2010 17:34:11 +0000 (10:34 -0700)
commit30d1872d9eb3663b4cf7bdebcbf5cd465674cced
treee3771c93ad38ad5e8f9d8c70a0915afb81423545
parent2eaa9cfdf33b8d7fb7aff27792192e0019ae8fc6
fat: fix buffer overflow in vfat_create_shortname()

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>
Cc: stable@kernel.org
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/fat/namei_vfat.c