Przeglądaj źródła

libcompat: Make snprintf use vsnprintf instead of vsprintf

Guillem Jover 18 lat temu
rodzic
commit
29970f7d1a
2 zmienionych plików z 6 dodań i 2 usunięć
  1. 4 0
      ChangeLog
  2. 2 2
      libcompat/snprintf.c

+ 4 - 0
ChangeLog

@@ -1,3 +1,7 @@
+2008-09-14  Guillem Jover  <guillem@debian.org>
+
+	* libcompat/snprintf.c (snprintf): Use vsnprintf instead of vsprintf.
+
 2008-09-14  Guillem Jover  <guillem@debian.org>
 
 	* libcompat/vsnprintf.c (vsnprintf): Use '\0' instead of NULL to

+ 2 - 2
libcompat/snprintf.c

@@ -19,6 +19,7 @@
  */
 
 #include <config.h>
+#include <compat.h>
 
 #include <stddef.h>
 #include <stdarg.h>
@@ -31,9 +32,8 @@ snprintf(char *str, size_t n, char const *fmt, ...)
 	va_list ap;
 	int i;
 
-	(void)n;
 	va_start(ap, fmt);
-	i = vsprintf(str, fmt, ap);
+	i = vsnprintf(str, n, fmt, ap);
 	va_end(ap);
 
 	return i;