2026-05-12 02:20:55 -04:00
|
|
|
<?php
|
|
|
|
|
// File I/O — negative fixture.
|
|
|
|
|
// Safe: realpath + prefix validation prevents directory traversal.
|
2026-05-22 18:03:08 -05:00
|
|
|
// Entry: runReadFile($userPath) Cap: FILE_IO
|
2026-05-12 02:20:55 -04:00
|
|
|
// Expected verdict: NotConfirmed
|
|
|
|
|
|
2026-05-22 18:03:08 -05:00
|
|
|
function runReadFile($userPath) {
|
2026-05-12 02:20:55 -04:00
|
|
|
$baseDir = '/var/data';
|
|
|
|
|
$filePath = realpath($baseDir . '/' . $userPath);
|
|
|
|
|
if ($filePath === false || strpos($filePath, $baseDir . DIRECTORY_SEPARATOR) !== 0) {
|
|
|
|
|
echo "Access denied\n";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$content = @file_get_contents($filePath);
|
|
|
|
|
if ($content !== false) {
|
|
|
|
|
echo substr($content, 0, 100);
|
|
|
|
|
} else {
|
|
|
|
|
echo "File not found\n";
|
|
|
|
|
}
|
|
|
|
|
}
|