mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-02-08 10:20:35 +01:00
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.
This commit is contained in:
parent
bc3c03a3f3
commit
331cc3f079
1 changed files with 2 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue