]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
lspci: Fix handling of truncated lines for msvcrt.dll
authorPali Rohár <pali@kernel.org>
Sun, 27 Feb 2022 23:06:00 +0000 (00:06 +0100)
committerPali Rohár <pali@kernel.org>
Fri, 15 Apr 2022 22:01:13 +0000 (00:01 +0200)
msvcrt.dll's vsnprintf() implementation does not fill terminating null byte
when overflow occurs and buffer size is returned.

ls-tree.c

index e845f662d71c46924d2fc8fe5a5166cfb78ec2b5..cc65ac472097b36d93100e7ba6821ebf873fecfd 100644 (file)
--- 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;