mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
- don't use /tmp as tmpdir and avoid endless loop when fopen or tmpnam failed
This commit is contained in:
parent
c89c62047c
commit
80d020011c
@ -42,9 +42,16 @@ class FileStream {
|
||||
stream_wrapper_register("myFile", "FileStream")
|
||||
or die("Failed to register protocol");
|
||||
|
||||
$tn = tempnam('/tmp', 'foo');
|
||||
$tmp_dir = __DIR__;
|
||||
$tn = tempnam($tmp_dir, 'foo');
|
||||
if (!$tn) {
|
||||
die("tempnam failed");
|
||||
}
|
||||
|
||||
$fp = fopen("myFile://" . urlencode($tn), "w+");
|
||||
if (!$fp) {
|
||||
die("fopen failed");
|
||||
}
|
||||
|
||||
fwrite($fp, "line1\n");
|
||||
fwrite($fp, "line2\n");
|
||||
|
Loading…
Reference in New Issue
Block a user