php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33268 iconv_strlen works only with a parameter of < 3 in length
Submitted: 2005-06-08 00:28 UTC Modified: 2005-06-09 01:51 UTC
From: markus dot lervik at necora dot fi Assigned:
Status: Closed Package: ICONV related
PHP Version: 5.* (2005-06-08) OS: *
Private report: No CVE-ID: None
 [2005-06-08 00:28 UTC] markus dot lervik at necora dot fi
Description:
------------
iconv_strlen seems to have a peculiar bug. It doesn't work when the string searched is less than three characters long (or an empty string), but reports

Notice: iconv_strlen() [function.iconv-strlen]: Unknown error (2) in /usr/local/apache/htdocs/test2.php on line 7

This is tested on PHP 5.0.3 and 5.1 from CVS (2005-06-07), tested with the built-in (glibc 2.3.3) iconv and libiconv 1.9.2 from gnu.org. 

This problem doesn't seem to surface on my Debian 3.1 development server, but I get it on my SuSE 9.2 desktop.

I have tried to set the encodings with iconv_set_encoding() and I have tried to set the encoding as a parameter to iconv_strlen(), both produce the same error.

The other iconv-functions (iconv_strpos, iconv_substr, iconv_strrpos) work fine.

Since the iconv-functions do not seem to work from the commandline (produces an Unknown error(29)), I cannot get a proper strace (strace seems to say that iconv is trying to seek on /dev/pts/5, which apparently is impossible). It doesn't crash apache either, so I'm not sure where I'd grab the backtrace.


List of modules:

mle@linux:~> php -m
[PHP Modules]
bz2
ctype
curl
dom
exif
gd
iconv
libxml
openssl
pcre
PDO
pdo_sqlite
pgsql
posix
session
SimpleXML
soap
SPL
standard
tokenizer
wddx
xml
xmlrpc
xsl
zlib

[Zend Modules]


PHP version: 

mle@linux:~> php --version
PHP 5.1.0-dev (cli) (built: Jun  7 2005 21:30:37) (DEBUG)
Copyright (c) 1997-2005 The PHP Group
Zend Engine v2.1.0-dev, Copyright (c) 1998-2004 Zend Technologies


configure line:

'./configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-openssl' '--with-curl' '--with-zlib' '--with-bz2' '--enable-exif' '--with-gd' '--with-pgsql=/usr' '--enable-soap' '--enable-wddx' '--without-sqlite' '--with-xmlrpc' '--with-xsl' '--with-jpeg-dir=/usr/local/' '--with-png-dir=/usr/local/' '--without-mysql' '--with-xslt-sablot' '--with-iconv=/usr/local/' '--enable-debug'




Reproduce code:
---------------
<?php
  $x = iconv_strlen("");
  var_dump($x);
?>

Expected result:
----------------
bool(false)

Actual result:
--------------
Notice: iconv_strlen() [function.iconv-strlen]: Unknown error (2) in /usr/local/apache/htdocs/test2.php on line 2
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-08 12:42 UTC] markus dot lervik at necora dot fi
My initial bug report regarded 5.0.3 and the latest HEAD from yesterday (2005-06-07).

I do still get the same problem with latest 5.1 (php-src) from CVS (checked out just 15 minutes ago, 2005-06-08), both with the glibc-provided iconv and the external libiconv (version 1.9.2)

<?php
$a =  iconv_strlen("");
var_dump($a);

$b = iconv_strlen("a");
var_dump($b);

$c = iconv_strlen("aa");
var_dump($c);

$d = iconv_strlen("aaa");
var_dump($d);

$e = iconv_strlen("aaaa");
var_dump($e);

?>

Notice: iconv_strlen() [function.iconv-strlen]: Unknown error (2) in /usr/local/apache/htdocs/test2.php on line 2
bool(false)

Notice: iconv_strlen() [function.iconv-strlen]: Unknown error (2) in /usr/local/apache/htdocs/test2.php on line 5
bool(false)

Notice: iconv_strlen() [function.iconv-strlen]: Unknown error (2) in /usr/local/apache/htdocs/test2.php on line 8
bool(false) 

int(3) 

int(4)
 [2005-06-08 17:31 UTC] sniper@php.net
Reproduced (having error_reporting = E_ALL helps :)

 [2005-06-09 01:51 UTC] iliaa@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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC