Browse Source

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 years ago
parent
commit
a42092d2a0
2 changed files with 12 additions and 0 deletions
  1. 11
    0
      src/core/vsprintf.c
  2. 1
    0
      src/include/vsprintf.h

+ 11
- 0
src/core/vsprintf.c View File

173
 	return i;
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
  * Write a formatted string to the console.
188
  * Write a formatted string to the console.
178
  *
189
  *

+ 1
- 0
src/include/vsprintf.h View File

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

Loading…
Cancel
Save