]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_scrub: fix null pointer crash in scrub_render_ino_descr
authorDarrick J. Wong <djwong@kernel.org>
Fri, 21 Nov 2025 16:39:37 +0000 (08:39 -0800)
committerAndrey Albershteyn <aalbersh@kernel.org>
Mon, 24 Nov 2025 14:35:05 +0000 (15:35 +0100)
Starting in Debian 13's libc6, passing a NULL format string to vsnprintf
causes the program to segfault.  Prior to this, the null format string
would be ignored.  Because @format is optional, let's explicitly steer
around the vsnprintf if there is no format string.  Also tidy whitespace
in the comment.

Found by generic/45[34] on Debian 13.

Cc: linux-xfs@vger.kernel.org # v6.10.0
Fixes: 9a8b09762f9a52 ("xfs_scrub: use parent pointers when possible to report file operations")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
scrub/common.c

index 9a33e2a9d54ed42cf422e70335e2a09a2ab95a8f..a567d2a3c2f14e6ffd51db2e434c315e72cdbd82 100644 (file)
@@ -401,7 +401,7 @@ within_range(
 /*
  * Render an inode number into a buffer in a format suitable for use in
  * log messages. The buffer will be filled with:
- *     "inode <inode number> (<ag number>/<ag inode number>)"
+ *     "inode <inode number> (<ag number>/<ag inode number>)"
  * If the @format argument is non-NULL, it will be rendered into the buffer
  * after the inode representation and a single space.
  */
@@ -503,8 +503,11 @@ report_inum:
        pathlen = ret;
 
 report_format:
-       va_start(args, format);
-       pathlen += vsnprintf(buf + pathlen, buflen - pathlen, format, args);
-       va_end(args);
+       if (format) {
+               va_start(args, format);
+               pathlen += vsnprintf(buf + pathlen, buflen - pathlen, format,
+                               args);
+               va_end(args);
+       }
        return pathlen;
 }