Przeglądaj źródła

Add a temporary snprintf, so that safely-written code can at least

compile, even if it won't yet be safe.
tags/v0.9.3
Michael Brown 18 lat temu
rodzic
commit
a42092d2a0
2 zmienionych plików z 12 dodań i 0 usunięć
  1. 11
    0
      src/core/vsprintf.c
  2. 1
    0
      src/include/vsprintf.h

+ 11
- 0
src/core/vsprintf.c Wyświetl plik

@@ -173,6 +173,17 @@ int sprintf(char *buf, const char *fmt, ...)
173 173
 	return i;
174 174
 }
175 175
 
176
+#warning "Remove this buffer-overflow-in-waiting at some point"
177
+int snprintf ( char *buf, size_t size, const char *fmt, ... ) {
178
+	va_list args;
179
+	int i;
180
+
181
+	va_start ( args, fmt );
182
+	i = vsprintf ( buf, fmt, args );
183
+	va_end ( args );
184
+	return i;
185
+}
186
+
176 187
 /**
177 188
  * Write a formatted string to the console.
178 189
  *

+ 1
- 0
src/include/vsprintf.h Wyświetl plik

@@ -45,6 +45,7 @@
45 45
  */
46 46
 
47 47
 extern int sprintf ( char *buf, const char *fmt, ... );
48
+extern int snprintf ( char *buf, size_t size, const char *fmt, ... );
48 49
 extern int printf ( const char *fmt, ... );
49 50
 
50 51
 #endif /* VSPRINTF_H */

Ładowanie…
Anuluj
Zapisz