[PATCH] ext4: Fix a test in ext4_decode_error()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The doc of snprintf() states that "If the return is greater than or equal
to @size, the resulting string is truncated".

So in order to "Check for truncated error codes...", we must check that the
returned value is < 16.

Fixes: ac27a0ec112a ("[PATCH] ext4: initial copy of files from ext3")
Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 38217422f938..f58fc7cc6f81 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -941,7 +941,7 @@ const char *ext4_decode_error(struct super_block *sb, int errno,
 		 * NULL. */
 		if (nbuf) {
 			/* Check for truncated error codes... */
-			if (snprintf(nbuf, 16, "error %d", -errno) >= 0)
+			if (snprintf(nbuf, 16, "error %d", -errno) < 16)
 				errstr = nbuf;
 		}
 		break;
-- 
2.34.1




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux