php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39032 strcspn stops on null character
Submitted: 2006-10-04 08:37 UTC Modified: 2006-10-04 11:15 UTC
From: tstarling at wikimedia dot org Assigned:
Status: Closed Package: Strings related
PHP Version: 5.1.6 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tstarling at wikimedia dot org
New email:
PHP Version: OS:

 

 [2006-10-04 08:37 UTC] tstarling at wikimedia dot org
Description:
------------
strcspn() incorrectly stops on null characters, as if the function was implemented with null-terminated strings. Confirmed on  PHP 5.1.6-pl4-gentoo (cli), PHP 5.1.4 Windows NT mod_php, PHP 5.1.4 FC4 cli. 

Reproduce code:
---------------
print strcspn(chr(0),"x").", ".strcspn(chr(1),"x")."\n"

Expected result:
----------------
1, 1

Actual result:
--------------
0, 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-04 11:15 UTC] tony2001@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in 5.2 and HEAD.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC