From 1564036166a316a4fd6160720f2487325ea0bce3 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 23 Apr 2018 09:06:20 +0200 Subject: [PATCH] Fix is_valid_section_name always returning true The if condition was if (!((*name >= 'A' && *name <= 'Z') || (*name >= 'a' || *name <= 'z') || *name == '\n' || *name == '\t')) which translates to if ((!(*name >= 'A' && *name <= 'Z') && !(*name >= 'a' || *name <= 'z') && *name != '\n' && *name != '\t')) which translates to if (((*name < 'A' || *name > 'Z') && (*name < 'a' && *name > 'z') && *name != '\n' && *name != '\t')) which will always be false since name can't be both smaller than a and bigger than z Found by gcc --- bus/desktop-file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bus/desktop-file.c b/bus/desktop-file.c index c824d566..2f41359a 100644 --- a/bus/desktop-file.c +++ b/bus/desktop-file.c @@ -382,7 +382,7 @@ is_valid_section_name (const char *name) while (*name) { - if (!((*name >= 'A' && *name <= 'Z') || (*name >= 'a' || *name <= 'z') || + if (!((*name >= 'A' && *name <= 'Z') || (*name >= 'a' && *name <= 'z') || *name == '\n' || *name == '\t')) return FALSE; -- 2.17.0