is_valid_section_name: Fix logical expression

Group names in desktop files may contain all ASCII characters, except
control characters and '[' and ']'. Rather than accepting all values,
thanks to a logical operator confusion found by GCC warning
-Wlogical-op, instead explicitly reject the invalid values.

Signed-off-by: David King <dking@redhat.com>
Fixes: https://gitlab.freedesktop.org/dbus/dbus/issues/208
(cherry picked from commit 3ef9e789c1)
This commit is contained in:
David King 2018-10-12 13:58:43 +01:00 committed by Simon McVittie
parent 6ef67cff6b
commit 2b09942986

View file

@ -382,8 +382,7 @@ is_valid_section_name (const char *name)
while (*name)
{
if (!((*name >= 'A' && *name <= 'Z') || (*name >= 'a' || *name <= 'z') ||
*name == '\n' || *name == '\t'))
if (*name <= 0x1f || *name >= 0x7f || *name == '[' || *name == ']')
return FALSE;
name++;