Skip to content

Commit 1bad124

Browse files
authored
codeql fixes (dotnet#107422)
* codeql fix * explicitly null terminating the status
1 parent b10f5c9 commit 1bad124

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/coreclr/hosts/corerun/corerun.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ namespace pal
455455
#else // !__APPLE__
456456
// Use procfs to detect if there is a tracer process.
457457
// See https://www.kernel.org/doc/html/latest/filesystems/proc.html
458-
char status[2048] = { 0 };
458+
char status[2048];
459459
int fd = ::open("/proc/self/status", O_RDONLY);
460460
if (fd == -1)
461461
{
@@ -471,6 +471,8 @@ namespace pal
471471
{
472472
// We have data. At this point we can likely make a strong decision.
473473
const char tracer_pid_name[] = "TracerPid:";
474+
// null terminate status
475+
status[bytes_read] = '\0';
474476
const char* tracer_pid_ptr = ::strstr(status, tracer_pid_name);
475477
if (tracer_pid_ptr == nullptr)
476478
return debugger_state_t::not_attached;

0 commit comments

Comments
 (0)