php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26721 strrpos() on strings containing null
Submitted: 2003-12-26 07:43 UTC Modified: 2003-12-26 15:07 UTC
From: norxh at binnews dot com Assigned:
Status: Closed Package: Strings related
PHP Version: 4.3.4 OS: RedHat 9
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: norxh at binnews dot com
New email:
PHP Version: OS:

 

 [2003-12-26 07:43 UTC] norxh at binnews dot com
Description:
------------
strrpos() does not return the proper values when the string contains a null character. 

strpos() works properly.

Reproduce code:
---------------
$test = "Hello";
var_dump(strpos($test, 'e'));
var_dump(strrpos($test, 'e'));
$test = "\x00Hello";
var_dump(strpos($test, 'e'));
var_dump(strrpos($test, 'e'));
$test = "Hello\x00";
var_dump(strpos($test, 'e'));
var_dump(strrpos($test, 'e'));

Expected result:
----------------
int(1)
int(1)
int(2)
int(2)
int(1)
int(1)

Actual result:
--------------
int(1)
int(1)
int(2)
bool(false)
int(1)
int(2)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-26 15:07 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

In PHP 4.3.X strrpos() is not binary safe, this is fixed in 
PHP 5.0 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 12:01:28 2024 UTC