From a18fe0b9a2ebf6b6d5d26cdeb91f71281ca2d347 Mon Sep 17 00:00:00 2001
From: Armin Luntzer <armin.luntzer@univie.ac.at>
Date: Thu, 19 Sep 2019 16:33:49 +0200
Subject: [PATCH] vsnprintf: insert termination in proper location

---
 lib/vsnprintf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/vsnprintf.c b/lib/vsnprintf.c
index 695a81c..5bfe4ad 100644
--- a/lib/vsnprintf.c
+++ b/lib/vsnprintf.c
@@ -1290,7 +1290,7 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap)
 
 		/* have we arrived at the end? */
 		if (!(*format))
-		    break;
+			break;
 
 		/* we have encountered a format specifier, try to evaluate it */
 		format++;
@@ -1310,7 +1310,7 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap)
 	if (size) {
 		if (str) {
 			if (buf < end)
-				buf[0]  = '\0';
+				buf[-1] = '\0';
 			else
 				end[-1] = '\0';
 		}
-- 
GitLab