Skip to content

Commit

Permalink
ubifs: fix snprintf() length check
Browse files Browse the repository at this point in the history
The snprintf() function returns the number of bytes (not including the
NUL terminator) which would have been printed if there were enough
space.  So it can be greater than UBIFS_DFS_DIR_LEN.  And actually if
it equals UBIFS_DFS_DIR_LEN then that's okay so this check is too
strict.

Fixes: 9a62029 ("ubifs: Export filesystem error counters")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
  • Loading branch information
Dan Carpenter authored and Richard Weinberger committed Dec 23, 2021
1 parent 5822563 commit d3de970
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/ubifs/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int ubifs_sysfs_register(struct ubifs_info *c)
n = snprintf(dfs_dir_name, UBIFS_DFS_DIR_LEN + 1, UBIFS_DFS_DIR_NAME,
c->vi.ubi_num, c->vi.vol_id);

if (n == UBIFS_DFS_DIR_LEN) {
if (n > UBIFS_DFS_DIR_LEN) {
/* The array size is too small */
ret = -EINVAL;
goto out_free;
Expand Down

0 comments on commit d3de970

Please sign in to comment.