|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #67386 wrong assignment in mbfl_identify_encoding2
Submitted: 2014-06-05 13:43 UTC Modified: 2017-07-22 20:07 UTC
From: delda at virgilio dot it Assigned:
Status: Not a bug Package: mbstring related
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
 [2014-06-05 13:43 UTC] delda at virgilio dot it
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) {

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


bad_variable_mbfilter2 (last revision 2014-07-07 14:50 UTC by delda at virgilio dot it)
bad_variable_mbfilter (last revision 2014-06-05 13:45 UTC by delda at virgilio dot it)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-05 23:08 UTC]
Could you send patch rather than whole file? or pull request?
 [2017-07-22 20:07 UTC]
-Status: Open +Status: Not a bug
 [2017-07-22 20:07 UTC]
The assignment is in the right place for what the code wants to do: If there are N possible encodings and N-1 of them have reported an error, then the code considers the last surviving one to be the correct one.

Whether that makes sense is another question, see bug #72933.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 05:01:27 2024 UTC