Commit fa05849e authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Translated sprintf calls into snprintf.

parent 073abfce
...@@ -129,7 +129,7 @@ void DEBUG_ExternalDebugger(void) ...@@ -129,7 +129,7 @@ void DEBUG_ExternalDebugger(void)
memset(pid_string, 0, DBG_BUFF_SIZE); memset(pid_string, 0, DBG_BUFF_SIZE);
/* make pid into string */ /* 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 */ /* now exec the debugger to get it's own clean memory space */
if (dbg_no_xterm) if (dbg_no_xterm)
......
...@@ -721,7 +721,7 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag, ...@@ -721,7 +721,7 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
strcat(arglist, ", "); strcat(arglist, ", ");
} }
DEBUG_READ_MEM_VERBOSE(ptr, &val, sizeof(val)); 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); strcat(arglist, argtmp);
} }
...@@ -736,7 +736,7 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag, ...@@ -736,7 +736,7 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
char* ptr = strrchr(module->module_name, '/'); char* ptr = strrchr(module->module_name, '/');
if (!ptr++) ptr = module->module_name; if (!ptr++) ptr = module->module_name;
sprintf( modbuf, " in %s", ptr); snprintf( modbuf, sizeof(modbuf), " in %s", ptr);
} }
else else
modbuf[0] = '\0'; modbuf[0] = '\0';
...@@ -765,7 +765,7 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag, ...@@ -765,7 +765,7 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
if( lineno != -1 ) if( lineno != -1 )
{ {
sprintf(linebuff, ":%d", lineno); snprintf(linebuff, sizeof(linebuff), ":%d", lineno);
lineinfo = linebuff; lineinfo = linebuff;
if( source != NULL ) if( source != NULL )
{ {
...@@ -779,22 +779,22 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag, ...@@ -779,22 +779,22 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag,
else sourcefile++; else sourcefile++;
if (addr->off == nearest->value.addr.off) 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); arglist, sourcefile, lineinfo, modbuf);
else 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, addr->off - nearest->value.addr.off,
arglist, sourcefile, lineinfo, modbuf ); arglist, sourcefile, lineinfo, modbuf );
} }
else else
{ {
if (addr->off == nearest->value.addr.off) 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 { else {
if (addr->seg && (nearest->value.addr.seg!=addr->seg)) if (addr->seg && (nearest->value.addr.seg!=addr->seg))
return NULL; return NULL;
else 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); addr->off - nearest->value.addr.off, arglist, modbuf);
} }
} }
......
...@@ -246,7 +246,7 @@ static void DEBUG_LoadModule16(HMODULE hModule, NE_MODULE* module, char* moduleA ...@@ -246,7 +246,7 @@ static void DEBUG_LoadModule16(HMODULE hModule, NE_MODULE* module, char* moduleA
cpnt += 1 + buf[0] + sizeof(WORD); cpnt += 1 + buf[0] + sizeof(WORD);
while (DEBUG_READ_MEM_VERBOSE(cpnt, buf, sizeof(buf)) && buf[0]) { 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)) { if (DEBUG_GetEP16(moduleAddr, module, *(WORD*)&buf[1 + buf[0]], &value.addr)) {
DEBUG_AddSymbol(epname, &value, NULL, SYM_WIN32 | SYM_FUNC); DEBUG_AddSymbol(epname, &value, NULL, SYM_WIN32 | SYM_FUNC);
} }
...@@ -257,7 +257,7 @@ static void DEBUG_LoadModule16(HMODULE hModule, NE_MODULE* module, char* moduleA ...@@ -257,7 +257,7 @@ static void DEBUG_LoadModule16(HMODULE hModule, NE_MODULE* module, char* moduleA
if (!module->nrname_handle) return; /* No non-resident table */ if (!module->nrname_handle) return; /* No non-resident table */
cpnt = (char *)GlobalLock16(module->nrname_handle); cpnt = (char *)GlobalLock16(module->nrname_handle);
while (DEBUG_READ_MEM_VERBOSE(cpnt, buf, sizeof(buf)) && buf[0]) { 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)) { if (DEBUG_GetEP16(moduleAddr, module, *(WORD*)&buf[1 + buf[0]], &value.addr)) {
DEBUG_AddSymbol(epname, &value, NULL, SYM_WIN32 | SYM_FUNC); DEBUG_AddSymbol(epname, &value, NULL, SYM_WIN32 | SYM_FUNC);
} }
......
...@@ -215,7 +215,7 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end) ...@@ -215,7 +215,7 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
/* /*
* Still couldn't find it. Ask user for path to add. * 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)); DEBUG_ReadLine(zbuf, tmppath, sizeof(tmppath));
if ( tmppath[strlen(tmppath)-1] != '/' ) if ( tmppath[strlen(tmppath)-1] != '/' )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment