#25174 [NEW]: Wrong handling of readlink() in OS/Guess.php

From: Date: Wed, 20 Aug 2003 11:55:18 +0000
Subject: #25174 [NEW]: Wrong handling of readlink() in OS/Guess.php
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-20149@lists.php.net to get a copy of this message
From: mk362 at mch dot osram dot de Operating system: SuSE Linux 8.2 and 7.3 PHP version: 4.3.1 PHP Bug Type: PEAR related Bug description: Wrong handling of readlink() in OS/Guess.php 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 bug report at http://bugs.php.net/?id=25174&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25174&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25174&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=25174&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=25174&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=25174&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=25174&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=25174&r=support Expected behavior: http://bugs.php.net/fix.php?id=25174&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=25174&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=25174&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=25174&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25174&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=25174&r=dst IIS Stability: http://bugs.php.net/fix.php?id=25174&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=25174&r=gnused

« previous php.pear.dev (#20149) next »