php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: delda at virgilio dot it
New email:
PHP Version: OS:

 

 [2014-06-05 13:43 UTC] delda at virgilio dot it
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.


Patches

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)

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-05 23:08 UTC] yohgaki@php.net
Could you send patch rather than whole file? or pull request?
 [2017-07-22 20:07 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2017-07-22 20:07 UTC] nikic@php.net
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: Sun Sep 08 01:01:28 2024 UTC