File/Passwd.php - a small patch (PHP Notice: Undefined offset:..)
| From: | Bjoern Frantzen | Date: | Thu, 22 Aug 2002 20:57:30 +0000 |
| Subject: | File/Passwd.php - a small patch (PHP Notice: Undefined offset:..) | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-8588@lists.php.net to get a copy of this message | ||
PHP Notice: Undefined offset: 2 in /usr/share/pear/File/Passwd.php
on line 103
After seeing an amount of these in my logfiles, I saw that there isn't any
checking for an empty line in Passwd.php. In most (all?) the passwd-type
files I've seen the last entry is followed by a \n, making a blank line
which lead to a notice from explode.
The following patch should fix this.
--- php4/pear/File/Passwd.php~ 2002-07-08 20:11:18.000000000 +0200
+++ php4/pear/File/Passwd.php 2002-08-22 22:33:49.000000000 +0200
@@ -100,6 +100,9 @@
}
while(!feof($fp)) {
$line = fgets($fp, 128);
+ if (!strlen ($line)) {
+ continue;
+ }
list($user, $pass, $cvsuser) = explode(':', $line);
if(strlen($user)) {
$this->users[$user] = trim($pass);
--
Bjørn Frantzen