]> git.baikalelectronics.ru Git - kernel.git/commit
ubifs: fix snprintf() checking
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 11 May 2021 07:12:00 +0000 (10:12 +0300)
committerRichard Weinberger <richard@nod.at>
Fri, 18 Jun 2021 20:04:47 +0000 (22:04 +0200)
commit570b300e5edd61252d2a5887a2a9c56cbdda2185
tree04fc8d1e381f1720a2fd025a87b79bdcc4f8a24a
parentee7eb1babcb0ec7a62828ea44dfb23f97d25a7a0
ubifs: fix snprintf() checking

The snprintf() function returns the number of characters (not
counting the NUL terminator) that it would have printed if we
had space.

This buffer has UBIFS_DFS_DIR_LEN characters plus one extra for
the terminator.  Printing UBIFS_DFS_DIR_LEN is okay but anything
higher will result in truncation.  Thus the comparison needs to be
change from == to >.

These strings are compile time constants so this patch doesn't
affect runtime.

Fixes: d6122e42e999 ("UBIFS: lessen the size of debugging info data structure")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Alexander Dahl <ada@thorsis.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/debug.c
fs/ubifs/debug.c