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-prev] [day] [month] [year] [list]
Message-ID: <20230912014956.GB1182921@mit.edu>
Date:   Mon, 11 Sep 2023 21:49:56 -0400
From:   "Theodore Ts'o" <tytso@....edu>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc:     Andreas Dilger <adilger.kernel@...ger.ca>,
        Dave Kleikamp <shaggy@...tin.ibm.com>,
        Andrew Morton <akpm@...l.org>, linux-kernel@...r.kernel.org,
        kernel-janitors@...r.kernel.org, linux-ext4@...r.kernel.org
Subject: Re: [PATCH] ext4: Fix a test in ext4_decode_error()

On Sat, Sep 09, 2023 at 06:07:02PM +0200, Christophe JAILLET wrote:
> 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>

This patch is not needed.  It's fine if snprintf truncates the string,
since it will still be null terminated.  This was checking for the
case where snprintf() returns an error, and the comment was
misleading.

Looking that the current implementation of the kernel snprintf, it
will never return a negative number, and nbuf is always passed in from
the callers, so it could be changed to

		snprintf(nbuf, 16, "error %d", -errno);
		errstr = nbuf;
		
But what is currently there is certainly valid.

						- Ted

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ