Req #67386 [NEW]: wrong assignment in mbfl_identify_encoding2

From: Date: Thu, 05 Jun 2014 13:43:54 +0000
Subject: Req #67386 [NEW]: wrong assignment in mbfl_identify_encoding2
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186069@lists.php.net to get a copy of this message
From:             delda at virgilio dot it
Operating system: All
PHP version:      Irrelevant
Package:          mbstring related
Bug Type:         Feature/Change Request
Bug description:wrong assignment in mbfl_identify_encoding2

Description:
------------
I think that in the function 'mbfl_identify_encoding2' (in
ext/mbstring/libmbfl/mbfl/mbfilter.c), the variable 'bad' was
instantiated in a wrong place.

The same is in 'mbfl_encoding_detector_feed' and
'mbfl_identify_encoding'

Test script:
---------------
	if (p != NULL) {
		bad = 0;
		while (n > 0) {
			for (i = 0; i < num; i++) {
				[...]
			}
			if ((num - 1) <= bad && !strict) {
				break;
			}
			p++;
			n--;
		}
	}

I think that 'bad' variable must be inner the while cycle, otherwise the
if control on bad number detect is very poor.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=67386&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=67386&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=67386&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=67386&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=67386&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=67386&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=67386&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=67386&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=67386&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=67386&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=67386&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=67386&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=67386&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=67386&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67386&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=67386&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=67386&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=67386&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67386&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=67386&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=67386&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#186069) next »