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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Tue Mar 19 05:01:29 2024 UTC