diff options
Diffstat (limited to 'src/pal/src/thread/process.cpp')
-rw-r--r-- | src/pal/src/thread/process.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/pal/src/thread/process.cpp b/src/pal/src/thread/process.cpp index 315145dc03..a64bfb8ab1 100644 --- a/src/pal/src/thread/process.cpp +++ b/src/pal/src/thread/process.cpp @@ -2049,18 +2049,18 @@ GetProcessIdDisambiguationKey(DWORD processId, UINT64 *disambiguationKey) // According to `man proc`, the second field in the stat file is the filename of the executable, // in parentheses. Tokenizing the stat file using spaces as separators breaks when that name - // has spaces in it, so we start using sscanf after skipping everything up to and including the + // has spaces in it, so we start using sscanf_s after skipping everything up to and including the // last closing paren and the space after it. char *scanStartPosition = strrchr(line, ')') + 2; // All the format specifiers for the fields in the stat file are provided by 'man proc'. - int sscanfRet = sscanf(scanStartPosition, + int sscanfRet = sscanf_s(scanStartPosition, "%*c %*d %*d %*d %*d %*d %*u %*lu %*lu %*lu %*lu %*lu %*lu %*ld %*ld %*ld %*ld %*ld %*ld %llu \n", &starttime); if (sscanfRet != 1) { - _ASSERTE(!"Failed to parse stat file contents with sscanf."); + _ASSERTE(!"Failed to parse stat file contents with sscanf_s."); return FALSE; } @@ -2095,7 +2095,7 @@ PAL_GetTransportPipeName(char *name, DWORD id, const char *suffix) // also try to use 0 as the value. _ASSERTE(ret == TRUE || disambiguationKey == 0); - int chars = _snprintf(name, MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH, PipeNameFormat, id, disambiguationKey, suffix); + int chars = snprintf(name, MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH, PipeNameFormat, id, disambiguationKey, suffix); _ASSERTE(chars > 0 && chars < MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH); } @@ -2690,7 +2690,7 @@ CreateProcessModules( char moduleName[PATH_MAX]; int size; - if (sscanf(line, "__TEXT %p-%p [ %dK] %*[-/rwxsp] SM=%*[A-Z] %s\n", &startAddress, &endAddress, &size, moduleName) == 4) + if (sscanf_s(line, "__TEXT %p-%p [ %dK] %*[-/rwxsp] SM=%*[A-Z] %s\n", &startAddress, &endAddress, &size, moduleName, _countof(moduleName)) == 4) { bool dup = false; for (ProcessModules *entry = listHead; entry != NULL; entry = entry->Next) @@ -2768,7 +2768,7 @@ exit: int devHi, devLo, inode; char moduleName[PATH_MAX]; - if (sscanf(line, "%p-%p %*[-rwxsp] %p %x:%x %d %s\n", &startAddress, &endAddress, &offset, &devHi, &devLo, &inode, moduleName) == 7) + if (sscanf_s(line, "%p-%p %*[-rwxsp] %p %x:%x %d %s\n", &startAddress, &endAddress, &offset, &devHi, &devLo, &inode, moduleName, _countof(moduleName)) == 7) { if (inode != 0) { |