diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2021-05-11 09:12:00 +0200 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2021-06-18 22:04:47 +0200 |
commit | be076fdf8369f3b4842362c64cd681f3d498f3dd (patch) | |
tree | 04fc8d1e381f1720a2fd025a87b79bdcc4f8a24a /drivers/mtd/ubi | |
parent | ubifs: journal: Fix error return code in ubifs_jnl_write_inode() (diff) | |
download | linux-be076fdf8369f3b4842362c64cd681f3d498f3dd.tar.xz linux-be076fdf8369f3b4842362c64cd681f3d498f3dd.zip |
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: ae380ce04731 ("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>
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r-- | drivers/mtd/ubi/debug.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index ac2bdba8bb1a..3c0c8eca4d51 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -511,7 +511,7 @@ int ubi_debugfs_init_dev(struct ubi_device *ubi) n = snprintf(d->dfs_dir_name, UBI_DFS_DIR_LEN + 1, UBI_DFS_DIR_NAME, ubi->ubi_num); - if (n == UBI_DFS_DIR_LEN) { + if (n > UBI_DFS_DIR_LEN) { /* The array size is too small */ return -EINVAL; } |