xserver: Branch 'master'
James Cloos
cloos at kemper.freedesktop.org
Tue Jul 22 21:06:54 PDT 2008
os/oscolor.c | 2 ++
1 file changed, 2 insertions(+)
New commits:
commit 331cc3f0799a54910a99484264f76569beeee55a
Author: James Cloos <cloos at jhcloos.com>
Date: Wed Jul 23 00:01:43 2008 -0400
Fix LookupColor
Using strncasecmp(3) with the lenght of the user-supplied colour name
will result in a false positive when the db key starts out with the
same string.
Eg, blue will also match BlueViolet (aka blue violet).
Since the shorter strings occur first in the database, avoid such
errors by treating a 0 result from strncasecmp(3) as a positive result
when the keyâs length is longer than the supplied stringâs.
diff --git a/os/oscolor.c b/os/oscolor.c
index cc45aaf..69eadc2 100644
--- a/os/oscolor.c
+++ b/os/oscolor.c
@@ -1590,6 +1590,8 @@ OsLookupColor(int screen,
mid = (low + high) / 2;
c = &BuiltinColors[mid];
r = strncasecmp (&BuiltinColorNames[c->name], name, len);
+ if (r == 0 && strlen (&BuiltinColorNames[c->name]) > len)
+ r++;
if (r == 0)
{
*pred = c->red * 0x101;
More information about the xorg-commit
mailing list