is_valid_section_name: Fix logical expression
authorDavid King <dking@redhat.com>
Fri, 12 Oct 2018 12:58:43 +0000 (13:58 +0100)
committerSimon McVittie <smcv@collabora.com>
Wed, 17 Apr 2019 12:38:05 +0000 (13:38 +0100)
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 3ef9e789c1b99f420078f4debabd4f5c4fa0a748)

bus/desktop-file.c

index 4459858..d91439b 100644 (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++;