php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12626 string to int incorrect if string containts 0 characters
Submitted: 2001-08-07 12:36 UTC Modified: 2002-08-14 17:33 UTC
From: stefan dot priebsch at e-novative dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.6 OS: win32
Private report: No CVE-ID: None
 [2001-08-07 12:36 UTC] stefan dot priebsch at e-novative dot de
if you convert a string containing chr(0) characters to an int, php cuts off conversion on reaching the first ascii 0. The resulting integer is incorrect, of course.

I found it out having a string constructed of concatenated single characters which would not convert correctly. However, checking the string length would show more characters than those visible.

Basic string handling stuff seems to work ok on those strings, however. This seems weird because I would have expected php to consider the first 0 character terminate the string, which it does not. Or does it?

Stefan



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-07 17:33 UTC] jeroen@php.net
Reworded: str->int conversion isn't binary safe (strtol isn't...).

A fix would make the commonly (implicitely) used str->int conversion slower... I can think of a few ways to fix this, but didn't check the performance impact.

In PHP, everything is supposed to work regardless of ascii 0 bytes in a string.
 [2002-08-14 17:33 UTC] tal@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 03:01:29 2024 UTC