aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gray2005-04-09 01:52:44 +0000
committerJonathan Gray2005-04-09 01:52:44 +0000
commit24c92d00919500a725a6d4c4797b48088b56431f (patch)
tree3473f42551f3263c3aa586e48d2648f251f293f3
parentaff66038f3fd5b0e5af49c94c7f0a5270981f7cf (diff)
downloadscummvm-rg350-24c92d00919500a725a6d4c4797b48088b56431f.tar.gz
scummvm-rg350-24c92d00919500a725a6d4c4797b48088b56431f.tar.bz2
scummvm-rg350-24c92d00919500a725a6d4c4797b48088b56431f.zip
Remove usage of vsprintf in favour of vsnprintf and make
more use of STRINGBUFLEN. Some ports may need a new stub for this, discussed with Chrilith. svn-id: r17463
-rw-r--r--backends/gp32/debug-gdbstub-usb.cpp2
-rw-r--r--backends/gp32/gp32.cpp4
-rw-r--r--backends/wince/missing/missing.cpp2
-rw-r--r--base/engine.cpp2
-rw-r--r--gob/debug.cpp4
-rw-r--r--scumm/debugger.cpp2
-rw-r--r--scumm/scumm.cpp2
-rw-r--r--simon/charset.cpp2
-rw-r--r--sky/control.cpp8
-rw-r--r--sound/softsynth/mt32.cpp2
-rw-r--r--sword1/control.cpp2
-rw-r--r--tools/convbdf.c4
-rw-r--r--tools/md5table.c4
13 files changed, 18 insertions, 22 deletions
diff --git a/backends/gp32/debug-gdbstub-usb.cpp b/backends/gp32/debug-gdbstub-usb.cpp
index 14ab38d7d6..15328c1511 100644
--- a/backends/gp32/debug-gdbstub-usb.cpp
+++ b/backends/gp32/debug-gdbstub-usb.cpp
@@ -994,7 +994,7 @@ void DEBUG_Print(char *pFormat, ...)
if (!g_GDBConnected) return;
va_start(VaList , pFormat);
- vsprintf(Temp , pFormat , VaList);
+ vsnprintf(Temp, 0x100, pFormat , VaList);
va_end(VaList);
iLength = strlen(Temp);
diff --git a/backends/gp32/gp32.cpp b/backends/gp32/gp32.cpp
index 0ff9827a0a..1d1a4adc58 100644
--- a/backends/gp32/gp32.cpp
+++ b/backends/gp32/gp32.cpp
@@ -2430,7 +2430,7 @@ int gpprintf(const char *fmt, ...) {
return 0;
busy = true;
va_start(marker, fmt);
- vsprintf(s, fmt, marker);
+ vsnprintf(s, 1024, fmt, marker);
va_end(marker);
#ifdef GPDEBUG
@@ -2460,7 +2460,7 @@ int gpfprintf(FILE *stream, const char *fmt, ...) {
va_list marker;
va_start(marker, fmt);
- vsprintf(s, fmt, marker);
+ vsnprintf(s, 256, fmt, marker);
va_end(marker);
return fwrite(s, 1, strlen(s), stream);
diff --git a/backends/wince/missing/missing.cpp b/backends/wince/missing/missing.cpp
index de4fc8a07b..198e0b8a93 100644
--- a/backends/wince/missing/missing.cpp
+++ b/backends/wince/missing/missing.cpp
@@ -567,7 +567,7 @@ int fprintf(FILE *stream, const char *format, ...) {
va_list va;
va_start(va, format);
- vsprintf(buf, format, va);
+ vsnprintf(buf, 1024, format, va);
va_end(va);
if (buf[strlen(buf) - 1] == '\n') {
diff --git a/base/engine.cpp b/base/engine.cpp
index cfea95c193..df3f49cb57 100644
--- a/base/engine.cpp
+++ b/base/engine.cpp
@@ -92,7 +92,7 @@ void NORETURN CDECL error(const char *s, ...) {
va_list va;
va_start(va, s);
- vsprintf(buf_input, s, va);
+ vsnprintf(buf_input, STRINGBUFLEN, s, va);
va_end(va);
if (g_engine) {
diff --git a/gob/debug.cpp b/gob/debug.cpp
index ff1a8a9440..1cc9e8ad32 100644
--- a/gob/debug.cpp
+++ b/gob/debug.cpp
@@ -26,7 +26,7 @@
namespace Gob {
static int16 logFile = -2;
-static char buf[256];
+static char buf[STRINGBUFLEN];
extern uint32 always0_dword_23EC_560;
@@ -50,7 +50,7 @@ void log_write(const char *format, ...) {
log_init();
if (logFile >= 0) {
- vsprintf(buf, format, lst);
+ vsnprintf(buf, STRINGBUFLEN, format, lst);
write(logFile, buf, strlen(buf));
}
diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp
index 056ade82ee..008c991b03 100644
--- a/scumm/debugger.cpp
+++ b/scumm/debugger.cpp
@@ -51,7 +51,7 @@ void CDECL debugC(int channel, const char *s, ...) {
return;
va_start(va, s);
- vsprintf(buf, s, va);
+ vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
debug(buf);
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index f8d2c209de..ff617c1a61 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -2924,7 +2924,7 @@ char ScummEngine::displayMessage(const char *altButton, const char *message, ...
va_list va;
va_start(va, message);
- vsprintf(buf, message, va);
+ vsnprintf(buf, STRINGBUFLEN, message, va);
va_end(va);
GUI::MessageDialog dialog(buf, "OK", altButton);
diff --git a/simon/charset.cpp b/simon/charset.cpp
index 1fd55f74fa..5996b4ed12 100644
--- a/simon/charset.cpp
+++ b/simon/charset.cpp
@@ -223,7 +223,7 @@ void SimonEngine::showMessageFormat(const char *s, ...) {
va_list va;
va_start(va, s);
- vsprintf(buf, s, va);
+ vsnprintf(buf, STRINGBUFLEN, s, va);
va_end(va);
if (!_fcs_data_1[_fcs_unk_1]) {
diff --git a/sky/control.cpp b/sky/control.cpp
index 22f1840249..a6179f48bf 100644
--- a/sky/control.cpp
+++ b/sky/control.cpp
@@ -1053,15 +1053,11 @@ bool Control::loadSaveAllowed(void) {
}
int Control::displayMessage(const char *altButton, const char *message, ...) {
-#ifdef __PALM_OS__
- char buf[256]; // 1024 is too big overflow the stack
-#else
- char buf[1024];
-#endif
+ char buf[STRINGBUFLEN];
va_list va;
va_start(va, message);
- vsprintf(buf, message, va);
+ vsnprintf(buf, STRINGBUFLEN, message, va);
va_end(va);
GUI::MessageDialog dialog(buf, "OK", altButton);
diff --git a/sound/softsynth/mt32.cpp b/sound/softsynth/mt32.cpp
index a62b2459f5..13502ed4df 100644
--- a/sound/softsynth/mt32.cpp
+++ b/sound/softsynth/mt32.cpp
@@ -174,7 +174,7 @@ static MT32Emu::File *MT32_OpenFile(void *userData, const char *filename, MT32Em
static void MT32_PrintDebug(void *userData, const char *fmt, va_list list) {
char buf[512];
if (((MidiDriver_MT32 *)userData)->_initialising) {
- vsprintf(buf, fmt, list);
+ vsnprintf(buf, 512, fmt, list);
buf[70] = 0; // Truncate to a reasonable length
drawMessage(1, buf);
}
diff --git a/sword1/control.cpp b/sword1/control.cpp
index 40f5604004..d8d95a0571 100644
--- a/sword1/control.cpp
+++ b/sword1/control.cpp
@@ -702,7 +702,7 @@ int Control::displayMessage(const char *altButton, const char *message, ...) {
va_list va;
va_start(va, message);
- vsprintf(buf, message, va);
+ vsnprintf(buf, STRINGBUFLEN, message, va);
va_end(va);
GUI::MessageDialog dialog(buf, "OK", altButton);
diff --git a/tools/convbdf.c b/tools/convbdf.c
index 9053e6fcf0..fe3377f032 100644
--- a/tools/convbdf.c
+++ b/tools/convbdf.c
@@ -101,7 +101,7 @@ void error(const char *s, ...) {
va_list va;
va_start(va, s);
- vsprintf(buf, s, va);
+ vsnprintf(buf, 1024, s, va);
va_end(va);
fprintf(stderr, "ERROR: %s!\n", buf);
@@ -114,7 +114,7 @@ void warning(const char *s, ...) {
va_list va;
va_start(va, s);
- vsprintf(buf, s, va);
+ vsnprintf(buf, 1024, s, va);
va_end(va);
fprintf(stderr, "WARNING: %s!\n", buf);
diff --git a/tools/md5table.c b/tools/md5table.c
index 78b0c18963..5bd7dc20ea 100644
--- a/tools/md5table.c
+++ b/tools/md5table.c
@@ -31,7 +31,7 @@ void error(const char *s, ...) {
va_list va;
va_start(va, s);
- vsprintf(buf, s, va);
+ vsnprintf(buf, 1024, s, va);
va_end(va);
fprintf(stderr, "ERROR: %s!\n", buf);
@@ -44,7 +44,7 @@ void warning(const char *s, ...) {
va_list va;
va_start(va, s);
- vsprintf(buf, s, va);
+ vsnprintf(buf, 1024, s, va);
va_end(va);
fprintf(stderr, "WARNING: %s!\n", buf);