xfs_scrub: fix null pointer crash in scrub_render_ino_descr
PATCH 1/1 xfs_scrub: fix null pointer crash in scrub_render_ino_descr
From: Darrick J. Wong <[email protected]>
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.
--- scrub/common.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
scrub/common.c +7 -4
@@ -404,7 +404,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. */
@@ -506,8 +506,11 @@ scrub_render_ino_descr( 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; }
Quoted 36 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
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 <[email protected]> # v6.10.0Fixes 9a8b09762f9a52 ("xfs_scrub: use parent pointers when possible to report file operations")Signed-off-by "Darrick J. Wong" <[email protected]>--- scrub/common.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)scrub/common.c +1
-2@@ -404,7 +404,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. */ @@ -506,8 +506,11 @@ scrub_render_ino_descr( pathlen = ret; report_format: -va_start (args, format);
scrub/common.c scrub_render_ino_descr( · line 516
Quoted 10 lines
scrub/common.c +6
-2- 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; }
lgtm
Signature · 1 line
- Andrey
Looks good: