From: "Theodore Ts'o" <tytso@mit.edu>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>,
Dave Kleikamp <shaggy@austin.ibm.com>,
Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: Fix a test in ext4_decode_error()
Date: Mon, 11 Sep 2023 21:49:56 -0400 [thread overview]
Message-ID: <20230912014956.GB1182921@mit.edu> (raw)
In-Reply-To: <2c0edffd8557807c6cd6d55111482c5cad7c8f2f.1694275603.git.christophe.jaillet@wanadoo.fr>
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@wanadoo.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
prev parent reply other threads:[~2023-09-12 2:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-09 16:07 Christophe JAILLET
2023-09-12 1:49 ` Theodore Ts'o [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230912014956.GB1182921@mit.edu \
--to=tytso@mit.edu \
--cc=adilger.kernel@dilger.ca \
--cc=akpm@osdl.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shaggy@austin.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®