Description
Found during the #567 cycle. MasterFingerprint::readUidForPid() (src/MasterFingerprint.php:114-135) reads the entire /proc/{pid}/status file and runs a multiline regex (preg_match('/^Uid:\s+(\d+)/m', ...)). The Uid: field is near the head of the file, so a bounded fread() of the first ~256 bytes plus strpos() avoids the full read and PCRE. UID cannot be read from /proc/{pid}/stat, so the file itself cannot be avoided — only the read size.
Reachable from ProcessInspector::readLinuxProcessSnapshot() (src/ProcessInspector.php:519) and MasterFingerprint::capture().
Where
- src/MasterFingerprint.php:114-135
Suggested fix
Bounded fread() of the head of /proc/{pid}/status + strpos()/parse, replacing the full file_get_contents() + /m regex.
Description
Found during the #567 cycle.
MasterFingerprint::readUidForPid()(src/MasterFingerprint.php:114-135) reads the entire/proc/{pid}/statusfile and runs a multiline regex (preg_match('/^Uid:\s+(\d+)/m', ...)). TheUid:field is near the head of the file, so a boundedfread()of the first ~256 bytes plusstrpos()avoids the full read and PCRE. UID cannot be read from/proc/{pid}/stat, so the file itself cannot be avoided — only the read size.Reachable from
ProcessInspector::readLinuxProcessSnapshot()(src/ProcessInspector.php:519) andMasterFingerprint::capture().Where
Suggested fix
Bounded
fread()of the head of/proc/{pid}/status+strpos()/parse, replacing the fullfile_get_contents()+/mregex.