|  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:
 [2006-10-04 08:37 UTC] tstarling at wikimedia dot org
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-04 11:15 UTC]
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
Thank you for the report, and for helping us make PHP better.

Fixed in 5.2 and HEAD.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Tue Dec 01 05:01:34 2015 UTC