aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2022-02-28 00:06:00 +0100
committerPali Rohár <pali@kernel.org>2022-04-16 00:01:13 +0200
commit7eb8b9473317562e0b66bd3e8c467e127d88dac8 (patch)
tree8bf6751403297c30db60e2bdde37ea01fdc79a74
parentd0b3d60f84fff7ab9ce99691fcf0db65b416e9ae (diff)
downloadpciutils-7eb8b9473317562e0b66bd3e8c467e127d88dac8.tar.gz
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.
-rw-r--r--ls-tree.c6
1 files changed, 5 insertions, 1 deletions
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;