]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ext4: fix diagnostic printf formats
authorDavid Laight <david.laight.linux@gmail.com>
Thu, 26 Mar 2026 20:18:04 +0000 (20:18 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 10 Apr 2026 01:54:33 +0000 (21:54 -0400)
The formats for non-terminated names should be "%.*s" not "%*.s".
The kernel currently treats "%*.s" as equivalent to "%*s" whereas
userspace requires it be equivalent to "%*.0s".
Neither is correct here.

Signed-off-by: David Laight <david.laight.linux@gmail.com>
Link: https://patch.msgid.link/20260326201804.3881-1-david.laight.linux@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/namei.c

index 0b8e25198b177bf0c6f1f6a15da587515abed603..838c01eb46ea203fe71ce52790e12dc5abc16f0d 100644 (file)
@@ -647,7 +647,7 @@ static struct stats dx_show_leaf(struct inode *dir,
                                        /* Directory is not encrypted */
                                        (void) ext4fs_dirhash(dir, de->name,
                                                de->name_len, &h);
-                                       printk("%*.s:(U)%x.%u ", len,
+                                       printk("%.*s:(U)%x.%u ", len,
                                               name, h.hash,
                                               (unsigned) ((char *) de
                                                           - base));
@@ -683,7 +683,7 @@ static struct stats dx_show_leaf(struct inode *dir,
                                                (void) ext4fs_dirhash(dir,
                                                        de->name,
                                                        de->name_len, &h);
-                                       printk("%*.s:(E)%x.%u ", len, name,
+                                       printk("%.*s:(E)%x.%u ", len, name,
                                               h.hash, (unsigned) ((char *) de
                                                                   - base));
                                        fscrypt_fname_free_buffer(
@@ -694,7 +694,7 @@ static struct stats dx_show_leaf(struct inode *dir,
                                char *name = de->name;
                                (void) ext4fs_dirhash(dir, de->name,
                                                      de->name_len, &h);
-                               printk("%*.s:%x.%u ", len, name, h.hash,
+                               printk("%.*s:%x.%u ", len, name, h.hash,
                                       (unsigned) ((char *) de - base));
 #endif
                        }