Bug #73506 [NEW]: php_url_parse_ex does not support resource id in url scheme
| From: | firestorm9 at gmail dot com | Date: | Sat, 12 Nov 2016 15:49:00 +0000 |
| Subject: | Bug #73506 [NEW]: php_url_parse_ex does not support resource id in url scheme | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-205324@lists.php.net to get a copy of this message | ||
From: firestorm9 at gmail dot com
Operating system: Linux
PHP version: 5.6.28
Package: Streams related
Bug Type: Bug
Bug description:php_url_parse_ex does not support resource id in url scheme
Description:
------------
The code in php_url_parse_ex was changed in a way that does no longer
support "Resource id #8" in a url scheme.
Reverting the code in ext/standard/url.c at line 220 fixes the issue:
// e = s + strcspn(s, "/?#");
if (!(p = memchr(s, '/', (ue - s)))) {
char *query, *fragment;
query = memchr(s, '?', (ue - s));
fragment = memchr(s, '#', (ue - s));
if (query && fragment) {
if (query > fragment) {
e = fragment;
} else {
e = query;
}
} else if (query) {
e = query;
} else if (fragment) {
e = fragment;
}
} else {
e = p;
}
Test script:
---------------
<?php
error_reporting(-1);
$host = 'any.sftp.host';
$port = 22;
$path = '/a/valid/path';
$username = 'user';
$password = 'pass';
$filename = 'zzz-test.txt';
$textOutput = "This is a test\n\ntest\ntest\ntest\ntest\ntest\n";
try {
$sshConnection = ssh2_connect($host, $port);
if (! $sshConnection) {
die("Failed to open connection to $host.\n");
}
echo "Connection established\n";
ssh2_auth_password($sshConnection, $username, $password);
$sftp = ssh2_sftp($sshConnection);
$sftpStream = @fopen("ssh2.sftp://$sftp" . $path .
$filename, 'w');
} catch(Exception $e) {
die("Failed to open SFTP connection to $host: " . $e->getMessage() .
"\n");
}
if (!$sftpStream) { die("Failed to open stream to $host\n"); }
echo "Stream opened";
try {
$writeResult = @fwrite($sftpStream, $orderOutput);
} catch(Exception $e) {
die("Failed to write $path/$filename to $host: " . $e->getMessage()
. "\n");
}
if ($writeResult === false) {
die("Failed to write $path/$filename to $host\n");
}
echo "Stream wrote successfully\n";
fclose($sftpStream);
?>
--
Edit bug report at https://bugs.php.net/bug.php?id=73506&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73506&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73506&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73506&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73506&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73506&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73506&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73506&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73506&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73506&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73506&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73506&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73506&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73506&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73506&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73506&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73506&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73506&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73506&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73506&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73506&r=mysqlcfg