[CRIU] [PATCH] compel: std_vprint_num returns a null-terminated string

joeln at il.ibm.com joeln at il.ibm.com
Mon May 7 14:03:18 MSK 2018


From: Joel Nider <joeln at il.ibm.com>

This function is an analogue to vsprintf(), and is used in very much the
same way. The caller expects the modified string pointer to be pointing to
a null-terminated string.

Signed-off-by: Joel Nider <joeln at il.ibm.com>
---
 compel/plugins/std/log.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/compel/plugins/std/log.c b/compel/plugins/std/log.c
index 2d622d6..ee02b69 100644
--- a/compel/plugins/std/log.c
+++ b/compel/plugins/std/log.c
@@ -143,6 +143,7 @@ int std_vprint_num(char *buf, int blen, int num, char **ps)
 	char *s;
 
 	s = &buf[blen - 1];
+	*s-- = 0; /* make sure the returned string is NULL terminated */
 
 	if (num < 0) {
 		neg = 1;
-- 
2.7.4



More information about the CRIU mailing list