lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <2c0edffd8557807c6cd6d55111482c5cad7c8f2f.1694275603.git.christophe.jaillet@wanadoo.fr>
Date:   Sat,  9 Sep 2023 18:07:02 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     "Theodore Ts'o" <tytso@....edu>,
        Andreas Dilger <adilger.kernel@...ger.ca>,
        Dave Kleikamp <shaggy@...tin.ibm.com>,
        Andrew Morton <akpm@...l.org>
Cc:     linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        linux-ext4@...r.kernel.org
Subject: [PATCH] ext4: Fix a test in ext4_decode_error()

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@...adoo.fr>
---
 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ