浏览代码

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 19 年前
父节点
当前提交
a42092d2a0
共有 2 个文件被更改,包括 12 次插入0 次删除
  1. 11
    0
      src/core/vsprintf.c
  2. 1
    0
      src/include/vsprintf.h

+ 11
- 0
src/core/vsprintf.c 查看文件

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 查看文件

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 */

正在加载...
取消
保存