diff mbox

ext4: fix transposition typo in format string

Message ID 1424441495-32581-1-git-send-email-linux@rasmusvillemoes.dk
State Accepted, archived
Headers show

Commit Message

Rasmus Villemoes Feb. 20, 2015, 2:11 p.m. UTC
According to C99, %*.s means the same as %*.0s, in other words, print
as many spaces as the field width argument says and effectively ignore
the string argument. That is certainly not what was meant here. The
kernel's printf implementation, however, treats it as if the . was not
there, i.e. as %*s. I don't know if de->name is nul-terminated or not,
but in any case I'm guessing the intention was to use de->name_len as
precision instead of field width.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
If de->name is not guaranteed to be nul-terminated, I suppose this is
even -stable material.

 fs/ext4/inline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Rasmus Villemoes March 2, 2015, 9:55 a.m. UTC | #1
Ping... (maybe I should have used a more dramatic subject - I do think
this is a real bug, but if not, I'd still like to get an explicit NAK.)

On Fri, Feb 20 2015, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:

> According to C99, %*.s means the same as %*.0s, in other words, print
> as many spaces as the field width argument says and effectively ignore
> the string argument. That is certainly not what was meant here. The
> kernel's printf implementation, however, treats it as if the . was not
> there, i.e. as %*s. I don't know if de->name is nul-terminated or not,
> but in any case I'm guessing the intention was to use de->name_len as
> precision instead of field width.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> If de->name is not guaranteed to be nul-terminated, I suppose this is
> even -stable material.
>
>  fs/ext4/inline.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
> index 4b143febf21f..8b64d715e476 100644
> --- a/fs/ext4/inline.c
> +++ b/fs/ext4/inline.c
> @@ -972,7 +972,7 @@ void ext4_show_inline_dir(struct inode *dir, struct buffer_head *bh,
>  	offset = 0;
>  	while ((void *)de < dlimit) {
>  		de_len = ext4_rec_len_from_disk(de->rec_len, inline_size);
> -		trace_printk("de: off %u rlen %u name %*.s nlen %u ino %u\n",
> +		trace_printk("de: off %u rlen %u name %.*s nlen %u ino %u\n",
>  			     offset, de_len, de->name_len, de->name,
>  			     de->name_len, le32_to_cpu(de->inode));
>  		if (ext4_check_dir_entry(dir, NULL, de, bh,
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o April 2, 2015, 8:47 p.m. UTC | #2
On Fri, Feb 20, 2015 at 03:11:35PM +0100, Rasmus Villemoes wrote:
> According to C99, %*.s means the same as %*.0s, in other words, print
> as many spaces as the field width argument says and effectively ignore
> the string argument. That is certainly not what was meant here. The
> kernel's printf implementation, however, treats it as if the . was not
> there, i.e. as %*s. I don't know if de->name is nul-terminated or not,
> but in any case I'm guessing the intention was to use de->name_len as
> precision instead of field width.

Applied, sorry for the delay.

(Note: the code is explicitly #ifdef'ed out so the only way the bug
would show up is if a developer explicitly modified the source to
#define INLINE_DIR_DEBUG, so it's not -stable material.)

						- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 4b143febf21f..8b64d715e476 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -972,7 +972,7 @@  void ext4_show_inline_dir(struct inode *dir, struct buffer_head *bh,
 	offset = 0;
 	while ((void *)de < dlimit) {
 		de_len = ext4_rec_len_from_disk(de->rec_len, inline_size);
-		trace_printk("de: off %u rlen %u name %*.s nlen %u ino %u\n",
+		trace_printk("de: off %u rlen %u name %.*s nlen %u ino %u\n",
 			     offset, de_len, de->name_len, de->name,
 			     de->name_len, le32_to_cpu(de->inode));
 		if (ext4_check_dir_entry(dir, NULL, de, bh,