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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 29 19:02:32 2025 UTC