php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2667 readfile() fails with Invalid URL specified
Submitted: 1999-11-04 20:34 UTC Modified: 2001-02-10 15:47 UTC
From: simon dot greaves at usp dot ac dot fj Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.12 OS: Digital UNIX 4.0D
Private report: No CVE-ID: None
 [1999-11-04 20:34 UTC] simon dot greaves at usp dot ac dot fj
Example script:

<?php readfile("http://www.usp.ac.fj/"); ?>

the above URL is valid, I got the same error with _any_ URL. I tried exactly the same from a RH6.0 Linux box running the same version of PHP and it works perfectly.

Seems to happen regardless of the modules compiled in, even if I simply type './configure'. I've compiled with both gcc 2.8.1 and DEC's C compiler (DEC C V5.6-075, using CFLAGS="-g -std").

Using a CGI version configured using 'CFLAGS=-g ./configure --enable-debug=yes', I tried running under gdb. The problem seems to be related to the use of a RE whilst parsing the HTTP username, password and port no from the URL (url.c:url_parse()). The RE compiles ok, but during the regexec() call, a function 'smatcher()' is called which calls 'fast()" which fails, returning NULL, causing url_parse to fail with the 'Invalid URL' message. Using the same environment on Linux, the same regexec() call calls 'lmatcher()' instead which then calls 'fast()' which succeeds. Unfortunately the RE code is fairly 'hairy'.

I've just tried it with php-3.0.13-dev fresh today from cvs and I get the same problem.

Dunno if it's related, but I have noticed a few other differences between the DU and Linux versions. DU tends to be a bit more pedantic, eg it will often complain about undefined variables when Linux does not. Also, Linux PHP will accept RE's in the pcre functions if they are surrounded by double or single quotes whereas DU PHP will often give the wrong results, or errors if the RE's are not in single quotes.

I renamed php3.ini and the problem still exists, so I didn't bother including it.

Could this be a 64 bit issue? Is this the latest version of the Henry Spencer RE libraries? Anything I can do to help, please let me know.

Thanks, Simon

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-11-10 15:15 UTC] simon dot greaves at usp dot ac dot fj
Just remembered about the --with-system-regex flag, configuring with this 
seems to fix the problem,  so it looks like a bug in the budled RE library.


 [1999-11-14 03:41 UTC] joey at cvs dot php dot net
There seems to have been a few bugs in the HS regex lib. This has been upgraded, and should (hopefully)
fix your problem...plz check this when 3.0.13 comes out?

 [2001-02-10 15:47 UTC] jimw@php.net
no feedback, closing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 13:01:30 2024 UTC