From: Tobias Stoeckmann Date: Wed, 8 Apr 2026 19:48:13 +0000 (+0200) Subject: libblkid: Fix parse_dev debug output X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d799ef7ef34a96d8fe356362c7139b331e197dc6;p=thirdparty%2Futil-linux.git libblkid: Fix parse_dev debug output 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 --- diff --git a/libblkid/src/read.c b/libblkid/src/read.c index 898ec3e4e..b922c5642 100644 --- a/libblkid/src/read.c +++ b/libblkid/src/read.c @@ -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;