From fa05849e67d7b972cb85e16854f44a369032fac7 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Tue, 11 Feb 2003 22:07:16 +0000 Subject: [PATCH] Translated sprintf calls into snprintf. --- programs/winedbg/ext_debugger.c | 2 +- programs/winedbg/hash.c | 14 +++++++------- programs/winedbg/module.c | 4 ++-- programs/winedbg/source.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/programs/winedbg/ext_debugger.c b/programs/winedbg/ext_debugger.c index f28fd0318db..6c913b0634a 100644 --- a/programs/winedbg/ext_debugger.c +++ b/programs/winedbg/ext_debugger.c @@ -129,7 +129,7 @@ void DEBUG_ExternalDebugger(void) memset(pid_string, 0, DBG_BUFF_SIZE); /* make pid into string */ - sprintf(pid_string, "%ld", (long) attach_pid); + snprintf(pid_string, sizeof(pid_string), "%ld", (long) attach_pid); /* now exec the debugger to get it's own clean memory space */ if (dbg_no_xterm) diff --git a/programs/winedbg/hash.c b/programs/winedbg/hash.c index 1c67a72d419..9d350ba516c 100644 --- a/programs/winedbg/hash.c +++ b/programs/winedbg/hash.c @@ -721,7 +721,7 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag, strcat(arglist, ", "); } DEBUG_READ_MEM_VERBOSE(ptr, &val, sizeof(val)); - sprintf(argtmp, "%s=0x%x", nearest->local_vars[i].name, val); + snprintf(argtmp, sizeof(argtmp), "%s=0x%x", nearest->local_vars[i].name, val); strcat(arglist, argtmp); } @@ -736,7 +736,7 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag, char* ptr = strrchr(module->module_name, '/'); if (!ptr++) ptr = module->module_name; - sprintf( modbuf, " in %s", ptr); + snprintf( modbuf, sizeof(modbuf), " in %s", ptr); } else modbuf[0] = '\0'; @@ -765,7 +765,7 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag, if( lineno != -1 ) { - sprintf(linebuff, ":%d", lineno); + snprintf(linebuff, sizeof(linebuff), ":%d", lineno); lineinfo = linebuff; if( source != NULL ) { @@ -779,22 +779,22 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag, else sourcefile++; if (addr->off == nearest->value.addr.off) - sprintf( name_buffer, "%s%s [%s%s]%s", nearest->name, + snprintf( name_buffer, sizeof(name_buffer), "%s%s [%s%s]%s", nearest->name, arglist, sourcefile, lineinfo, modbuf); else - sprintf( name_buffer, "%s+0x%lx%s [%s%s]%s", nearest->name, + snprintf( name_buffer, sizeof(name_buffer), "%s+0x%lx%s [%s%s]%s", nearest->name, addr->off - nearest->value.addr.off, arglist, sourcefile, lineinfo, modbuf ); } else { if (addr->off == nearest->value.addr.off) - sprintf( name_buffer, "%s%s%s", nearest->name, arglist, modbuf); + snprintf( name_buffer, sizeof(name_buffer), "%s%s%s", nearest->name, arglist, modbuf); else { if (addr->seg && (nearest->value.addr.seg!=addr->seg)) return NULL; else - sprintf( name_buffer, "%s+0x%lx%s%s", nearest->name, + snprintf( name_buffer, sizeof(name_buffer), "%s+0x%lx%s%s", nearest->name, addr->off - nearest->value.addr.off, arglist, modbuf); } } diff --git a/programs/winedbg/module.c b/programs/winedbg/module.c index add3bee47de..3a957b18739 100644 --- a/programs/winedbg/module.c +++ b/programs/winedbg/module.c @@ -246,7 +246,7 @@ static void DEBUG_LoadModule16(HMODULE hModule, NE_MODULE* module, char* moduleA cpnt += 1 + buf[0] + sizeof(WORD); while (DEBUG_READ_MEM_VERBOSE(cpnt, buf, sizeof(buf)) && buf[0]) { - sprintf(epname, "%s.%.*s", name, buf[0], &buf[1]); + snprintf(epname, sizeof(epname), "%s.%.*s", name, buf[0], &buf[1]); if (DEBUG_GetEP16(moduleAddr, module, *(WORD*)&buf[1 + buf[0]], &value.addr)) { DEBUG_AddSymbol(epname, &value, NULL, SYM_WIN32 | SYM_FUNC); } @@ -257,7 +257,7 @@ static void DEBUG_LoadModule16(HMODULE hModule, NE_MODULE* module, char* moduleA if (!module->nrname_handle) return; /* No non-resident table */ cpnt = (char *)GlobalLock16(module->nrname_handle); while (DEBUG_READ_MEM_VERBOSE(cpnt, buf, sizeof(buf)) && buf[0]) { - sprintf(epname, "%s.%.*s", name, buf[0], &buf[1]); + snprintf(epname, sizeof(epname), "%s.%.*s", name, buf[0], &buf[1]); if (DEBUG_GetEP16(moduleAddr, module, *(WORD*)&buf[1 + buf[0]], &value.addr)) { DEBUG_AddSymbol(epname, &value, NULL, SYM_WIN32 | SYM_FUNC); } diff --git a/programs/winedbg/source.c b/programs/winedbg/source.c index bb3038614d3..4b72975e62c 100644 --- a/programs/winedbg/source.c +++ b/programs/winedbg/source.c @@ -215,7 +215,7 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end) /* * Still couldn't find it. Ask user for path to add. */ - sprintf(zbuf, "Enter path to file '%s': ", sourcefile); + snprintf(zbuf, sizeof(zbuf), "Enter path to file '%s': ", sourcefile); DEBUG_ReadLine(zbuf, tmppath, sizeof(tmppath)); if ( tmppath[strlen(tmppath)-1] != '/' )