PHP :: Bug #13866 :: strtok() parses erroneously empty substrings - PHP 4.0.7RC2
php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13866 strtok() parses erroneously empty substrings - PHP 4.0.7RC2
Submitted: 2001-10-29 17:32 UTC Modified: 2001-11-02 14:21 UTC
From: rcpj at panix dot com Assigned:
Status: Closed Package: Strings related
PHP Version: 4.0.6 OS: Linux
Private report: No CVE-ID: None
 [2001-10-29 17:32 UTC] rcpj at panix dot com
NOTE, the PHP version is reported as 4.0.7RC2 but that's not in the predefined list on the form.
------

The function strtok() misparses strings where some fields are empty, such as #1 and #4 in the list below, 

1|carrot||(no adjective)
2|pepper|red|(adjective)
3|pepper|green|(adjective)
4|tomato||(no adjective)
5|apricot|dried|(adjective)

Compare the output of the test program (the code is listed below) running (under PHP 4.0.7RC2) at:

http://www.web-ho.com/PHP/test-module.php 

versus the same program (under PHP 4.0.3pl1) at:

http://www.pierrejelenc.com/PHP/test-module.php 

Both the Apache module and the CGI version in /usr/local/bin/php are affected.


============== test-module.php =============
<?php

$Item=file("test-data");

for ($i=0; $i<count($Item);$i++)
{
     $Number=strtok(chop($Item[$i]),"|");
     $Name=strtok("|");
     $Type=strtok("|");
     $Comment=strtok("|");

     print("$Type $Name: line #$Number $Comment<br>\n");
}

?>
</body></html>

===========================================

I am not in charge of program maintenance on either system, but I am the webmaster for several sites there. I was encouraged by the administrator of the machine on which web-ho.com is located to report this myself.

Cheers,

Pierre Jelenc
rcpj@panix.com

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-02 14:21 UTC] jmoore@php.net
fixed in CVS
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Aug 19 16:01:25 2018 UTC