Possible bug in mb.inc.php Possible bug in mb.inc.php
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Possible bug in mb.inc.php

Started by Pit, December 05, 2005, 11:54:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Pit

There seems to be a bug in include/mb.inc.php function mb_substr():

While trying to bridge cpg to ipb I have noticed that all group names of ipb have been imported only with the first character. This happened on a server where I didn't have activated mbstring library in php.ini. Testing the error in my local environment I found the bug in mb.inc.php.

In the original code of mb_substr you call array_slice always with parameter length (here $end) even when that parameter is null. In my php installation (4.4.1)  array_slice returns only the $start element of the array instead of the entire rest of it.

        function mb_substr($str, $start, $end=null) {
                global $mb_utf8_regex;
                preg_match_all("#$mb_utf8_regex".'|[\x00-\x7F]#', $str, $str);
                $str = array_slice($str[0], $start, $end);
                return implode('', $str);
        }


To avoid this behavior I have had to modify the function:
        function mb_substr($str, $start, $end=null) {
                global $mb_utf8_regex;
                preg_match_all("#$mb_utf8_regex".'|[\x00-\x7F]#', $str, $str);
                if ($end == null)
                    $str = array_slice($str[0], $start);
                else
                    $str = array_slice($str[0], $start, $end);
                return implode('', $str);
        }


Perhaps you can verify this as a bug.
I do not code for or support Invisionboard 2.x