Issue 125112 - CStringEqual can return true for non-equal c-strings
Summary: CStringEqual can return true for non-equal c-strings
Status: CLOSED FIXED
Alias: None
Product: General
Classification: Code
Component: code (show other issues)
Version: 4.0.0
Hardware: All All
: P3 Normal (vote)
Target Milestone: 4.1.1
Assignee: hdu@apache.org
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-18 11:34 UTC by hdu@apache.org
Modified: 2017-05-20 10:35 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: 4.2.0-dev
Developer Difficulty: ---
jsc: 4.1.1_release_blocker+


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description hdu@apache.org 2014-06-18 11:34:54 UTC
CStringEqual is a functor for testing whether two C-strings are equal. It has the problem that it returns true if the first string matches the start of the second string. It should only return true when the first string matches the second string fully.

No known bug has been introduced by this, but better be safe than sorry.
Comment 1 SVN Robot 2014-06-18 11:43:10 UTC
"hdu" committed SVN revision 1603416 into trunk:
#i125112# fix CStringHash functor to match full strings only
Comment 2 hdu@apache.org 2014-06-18 11:47:22 UTC
Fixed with the commit above.

The fix is safe and should be considered for the next bugfix release too.
Comment 3 jsc 2014-06-18 12:02:30 UTC
grant showstopper fix, it is considered as important preventive fix
Comment 4 SVN Robot 2014-06-18 12:15:21 UTC
"hdu" committed SVN revision 1603423 into branches/AOO410:
#i125112# fix CStringHash functor to match full strings only
Comment 5 hdu@apache.org 2014-06-18 12:17:17 UTC
The fix has been merged for the AOO 4.1.1 target.
Comment 6 zhengjiezxxy2010 2014-06-19 02:18:33 UTC
 struct CStringEqual
 {
 	bool operator()( const char* p1, const char* p2) const {
-		while( *p1)
+		while( *p1 != '\0')
 			if( *(p1++) != *(p2++))
 				return false;
-		return true;
+		return (*p2 == '\0');
 	}
 };

But if second string p2 is short than p1, is there a acess violation?
Comment 7 fanyuzhen 2014-07-07 08:19:51 UTC
It's verified fixed on Windows via build level testing
Comment 8 fanyuzhen 2014-07-11 03:08:53 UTC
No special problem found during build level testing on Linux and Mac.
So change status to fixed, but please reopen if any related problem found.