note 124347 added to function.time-sleep-until
| From: | divinity76 at gmail dot com | Date: | Mon, 28 Oct 2019 07:22:03 +0000 |
| Subject: | note 124347 added to function.time-sleep-until | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-212863@lists.php.net to get a copy of this message | ||
if you for some reason need a constant-time implementation of realpath(), try
<?php
function realpath_constant_time(string $path, float $target_seconds, bool
&$constant_time_success = null){
$start_time=microtime(true);
$ret=realpath($path);
$constant_time_success = @time_sleep_until($start_time+$target_seconds);
return $ret;
}
?>
for example, a realtime that always uses exactly 1 millisecond (should be more than enough for
SSD-based servers, perhaps rotating harddrive based servers may need something closer to 10
milliseconds, i don't know):
<?php
realpath_constant_time("/path/to/../to/file.txt",0.001,$constant_time_success);
?>
and you can use $constant_time_success to see if you needed more time (and thus failed to do
realpath() in constant-time), or if you succeeded.
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.168 (proxied: 46.46.192.207)
----
Manual Page -- http://php.net/manual/en/function.time-sleep-until.php
Edit -- https://master.php.net/note/edit/124347
Del: integrated -- https://master.php.net/note/delete/124347/integrated
Del: useless -- https://master.php.net/note/delete/124347/useless
Del: bad code -- https://master.php.net/note/delete/124347/bad+code
Del: spam -- https://master.php.net/note/delete/124347/spam
Del: non-english -- https://master.php.net/note/delete/124347/non-english
Del: in docs -- https://master.php.net/note/delete/124347/in+docs
Del: other reasons-- https://master.php.net/note/delete/124347
Reject -- https://master.php.net/note/reject/124347
Search -- https://master.php.net/manage/user-notes.php