From 7eb8b9473317562e0b66bd3e8c467e127d88dac8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Mon, 28 Feb 2022 00:06:00 +0100 Subject: [PATCH] lspci: Fix handling of truncated lines for msvcrt.dll msvcrt.dll's vsnprintf() implementation does not fill terminating null byte when overflow occurs and buffer size is returned. --- ls-tree.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ls-tree.c b/ls-tree.c index e845f66..cc65ac4 100644 --- a/ls-tree.c +++ b/ls-tree.c @@ -239,7 +239,11 @@ tree_printf(char *line, char *p, char *fmt, ...) p += space; } else if (res >= space) - p += space; + { + /* Ancient C libraries do not truncate the output properly. */ + *(p+space-1) = 0; + p += space; + } else p += res; -- 2.39.5