From a42092d2a05bbaf102121e655b5b4c240c8f8e8e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 30 Apr 2006 12:01:31 +0000 Subject: [PATCH] Add a temporary snprintf, so that safely-written code can at least compile, even if it won't yet be safe. --- src/core/vsprintf.c | 11 +++++++++++ src/include/vsprintf.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/core/vsprintf.c b/src/core/vsprintf.c index e3ff7d9d..3c8e5b5c 100644 --- a/src/core/vsprintf.c +++ b/src/core/vsprintf.c @@ -173,6 +173,17 @@ int sprintf(char *buf, const char *fmt, ...) return i; } +#warning "Remove this buffer-overflow-in-waiting at some point" +int snprintf ( char *buf, size_t size, const char *fmt, ... ) { + va_list args; + int i; + + va_start ( args, fmt ); + i = vsprintf ( buf, fmt, args ); + va_end ( args ); + return i; +} + /** * Write a formatted string to the console. * diff --git a/src/include/vsprintf.h b/src/include/vsprintf.h index 122fcc66..7090d5c3 100644 --- a/src/include/vsprintf.h +++ b/src/include/vsprintf.h @@ -45,6 +45,7 @@ */ extern int sprintf ( char *buf, const char *fmt, ... ); +extern int snprintf ( char *buf, size_t size, const char *fmt, ... ); extern int printf ( const char *fmt, ... ); #endif /* VSPRINTF_H */