Bug 689984 - xps_strcasecmp() causes issues when expected to behave like strcasecmp()
Summary: xps_strcasecmp() causes issues when expected to behave like strcasecmp()
Status: NOTIFIED FIXED
Alias: None
Product: GhostXPS
Classification: Unclassified
Component: General (show other bugs)
Version: master
Hardware: All All
: P4 normal
Assignee: Tor Andersson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-28 21:49 UTC by Dave Geering
Modified: 2008-12-19 08:31 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
Patch for xps_strcasecmp() issue (543 bytes, patch)
2008-07-28 21:57 UTC, Dave Geering
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Geering 2008-07-28 21:49:46 UTC
In xpszip.c there is an error in xps_find_part() (line 160).

xps_find_part() uses a function xps_strcasecmp(), but xps_strcasecmp() will
always return zero (a match) if the first string is shorter than the second
string, which means that a lot of matches will be incorrect if xps_strcasecmp()
is expected to behave as strcasecmp() would.

I'm not sure about all events that would trigger this, but in my particular case
it was not deobfuscating fonts. The xps_new_glyph() function was calling
xps_find_part(), but xps_find_part() was always returning the first "part" of
the context because the first part's name was shorter than font part's name. By
changing "xps_strcasecmp()" to "strcasecmp()" in xpszip.c:xps_find_part(),
obfuscated fonts become deobfuscated and loaded correctly.
Comment 1 Dave Geering 2008-07-28 21:57:15 UTC
Created attachment 4246 [details]
Patch for xps_strcasecmp() issue

Patch using -p1 and inside xps directory.
Comment 2 Dave Geering 2008-07-29 15:18:10 UTC
Upon further investigation, I've found that xps_strcasecmp() returns a match
when string1 is shorter than string2 only when the case is different! After
reviewing the code for xps_strcasecmp() I found it uses another compatibility
function xps_tolower(). The logic in xps_tolower() is the problem.

Line 7 of xpsmem.c:

if (x >= 'A' || x <= 'Z')

should read

if (x >= 'A' && x <= 'Z')


The attached patch is therefore not an ideal solution considering strcasecmp is
not available on all platforms.
Comment 3 Tor Andersson 2008-07-30 07:54:26 UTC
This bug was discovered and fixed a long time ago. You may want to update to a newer version of the 
source.
Comment 4 Dave Geering 2008-07-30 14:56:15 UTC
Sorry to bring up an old bug. I will use a snapshot rather than the 1.52 source.