#45923 [NoF->Opn]: mb_st[r]ripos() offset not handled correctly
| From: | d_kelsey at uk dot ibm dot com | Date: | Mon, 19 Jan 2009 17:25:17 +0000 |
| Subject: | #45923 [NoF->Opn]: mb_st[r]ripos() offset not handled correctly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-133018@lists.php.net to get a copy of this message | ||
ID: 45923
User updated by: d_kelsey at uk dot ibm dot com
Reported By: d_kelsey at uk dot ibm dot com
-Status: No Feedback
+Status: Open
Bug Type: mbstring related
Operating System: Windows XP
PHP Version: 5.2.6
New Comment:
as of php 5.2.8 this bug is still present
Previous Comments:
------------------------------------------------------------------------
[2008-12-05 13:37:43] ant@php.net
I re-tested, this is still happening on the latest 5.2 snap.
------------------------------------------------------------------------
[2008-11-03 01:00:02] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2008-10-26 19:28:18] jani@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2008-08-26 16:07:42] d_kelsey at uk dot ibm dot com
Description:
------------
The offset checking in mb_stripos and mb_strripos doesn't match the
case sensitive equivalents with regard to character counts rather than
byte counts. More importantly entering a negative offset in mb_strripos
results in a "Offset not contained in string." message which was not
expected.
Suggested code changes.
mb_stripos function add the check:
if (offset < 0 || (unsigned long)offset > (unsigned
long)mbfl_strlen(&old_haystack)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in
string.");
RETURN_FALSE;
}
mb_strripos function add the check:
if ((offset > 0 && offset > mbfl_strlen(&old_haystack)) ||
(offset < 0 && -offset > mbfl_strlen(&old_haystack))) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Offset is greater than
the length of haystack string");
RETURN_FALSE;
}
php_mb_stripos function remove the check:
if (offset < 0 || (unsigned long)offset > haystack.len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in
string.");
break;
}
Reproduce code:
---------------
<?php
var_dump(mb_strripos("abc abc abc", "b", -3));
?>
Expected result:
----------------
int(5)
Actual result:
--------------
Warning: mb_strripos(): Offset not contained in string. in
C:\udata-eclipse\p8\a.phpcode\testmb.php on line 2
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45923&edit=1