#25174 [Csd]: Wrong handling of readlink() in OS/Guess.php
| From: | mk362 at mch dot osram dot de | Date: | Thu, 28 Aug 2003 09:23:00 +0000 |
| Subject: | #25174 [Csd]: Wrong handling of readlink() in OS/Guess.php | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-20724@lists.php.net to get a copy of this message | ||
ID: 25174
User updated by: mk362 at mch dot osram dot de
Reported By: mk362 at mch dot osram dot de
Status: Closed
Bug Type: PEAR related
Operating System: SuSE Linux 8.2, 7.3, 7.2
PHP Version: 4.3.2
Assigned To: nohn
New Comment:
Hi Nohn,
did you do the test case from the "reproduce code" section?
Even with an upgraded PEAR you will produce this error, since that code
wasn't changed at all.
Marko
Previous Comments:
------------------------------------------------------------------------
[2003-08-24 12:38:16] nohn@php.net
Hmmm... After upgrading to PEAR 1.2.1 by hand everything works fine. So
this already seems to be closed.
Verified this on another SuSE-Machine (SuSE 7.3)
------------------------------------------------------------------------
[2003-08-24 12:16:50] cellog@php.net
I don't have SuSE linux. nohn,do you have enough knowhow to provide a
patch for this? I can't be sure that anything I would do fixes this.
If not, just assign it back to me.
I can commit a patch you provide.
Greg
------------------------------------------------------------------------
[2003-08-24 10:13:05] nohn@php.net
verified on suse 7.2, php 4.3.2
downloading PEAR-1.2.1.tgz ...
...done: 83,126 bytes
Notice: Undefined offset: 1 in Guess.php on line 173
Warning: readlink(): Invalid argument in Guess.php on line 181
upgrade-all ok: PEAR 1.2.1
------------------------------------------------------------------------
[2003-08-20 06:55:18] mk362 at mch dot osram dot de
Description:
------------
Hi,
during upgrade of PEAR I noticed the following on my SuSE Linux 7.3:
---
Release Warnings
================
w
w
downloading PEAR-1.2.tgz ...
...done: 83,109 bytes
Warning: readlink() [http://www.php.net/function.readlink]: Invalid
argument in Guess.php on line 181
upgrade-all ok: PEAR 1.2
---
This didn't happen in SuSE 8.2, but I think just because the program
didn't come to that point.
Looking into the code revealed that there is a readlink() call without
error checking in line 181:
---
if (ereg('^libc-([.*])\.so$',
basename(readlink('/lib/libc.so.6')),
---
and in case libc.so.6 is a regular file this will return FALSE instead
of a string for basename() for both versions of my Linux.
I guess one should implement proper error checking here. Possibly this
was never tested anyway, because most systems might already circumvent
the problem by getting $major and $minor a step earlier via the call of
"/usr/bin/cpp".
Marko
Reproduce code:
---------------
<?php
error_reporting(0);
require_once('OS/Guess.php');
if(readlink('/lib/libc.so.6') == FALSE)
echo "Readlink call on /lib/libc.so.6 failed\n";
?>
Actual result:
--------------
Content-type: text/html
X-Powered-By: PHP/4.3.1
Readlink call on /lib/libc.so.6 failed
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25174&edit=1