]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: Fix parse_dev debug output
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 8 Apr 2026 19:48:13 +0000 (21:48 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 8 Apr 2026 19:48:13 +0000 (21:48 +0200)
A parse_dev debug line erroneously uses %*s instead of %.*s. While this
does not lead to out of boundary access because the line is properly
NUL-escaped by fgets, the output is incorrect.

Simply replace the ending char with NUL for debug, since the line is
modified a few lines below anyway. This offers more safety for
refactoring in the future if fgets is ever replaced with getline,
possibly leading to lines longer than INT_MAX.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
libblkid/src/read.c

index 898ec3e4ecc9e491222111620b1e19658479a35e..b922c56421082a4148aaa42338a5fe8e13aefbea 100644 (file)
@@ -187,8 +187,12 @@ static int parse_dev(blkid_cache cache, blkid_dev *dev, char **cp)
        start = skip_over_blank(start + 1);
        end = skip_over_word(start);
 
-       DBG(READ, ul_debug("device should be %*s",
-                              (int)(end - start), start));
+       ON_DBG(READ, {
+               char c = *end;
+               *end = '\0';
+               ul_debug("device should be %s", start);
+               *end = c;
+       });
 
        if (**cp == '>')
                *cp = end;