From 1dc042ae12be9aa0a834eba7747f78079d06fcde Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 26 Aug 2022 10:36:45 +0200 Subject: [PATCH] condition: check for last not first ')' in firmware test expressions I possess a machine with ')' in its BIOS version string, which will cause the current parser to mistake it as the closing ')' of the smbios-fields() expression. Let's make sure we always fo for the last, not the first ')', hence. --- src/shared/condition.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/condition.c b/src/shared/condition.c index 3a09b493fc3..5c6e383679f 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -659,7 +659,7 @@ static int condition_test_firmware(Condition *c, char **env) { _cleanup_free_ char *dtc_arg = NULL; char *end; - end = strchr(arg, ')'); + end = strrchr(arg, ')'); if (!end || *(end + 1) != '\0') { log_debug("Malformed ConditionFirmware=%s", c->parameter); return false; @@ -676,7 +676,7 @@ static int condition_test_firmware(Condition *c, char **env) { _cleanup_free_ char *smbios_arg = NULL; char *end; - end = strchr(arg, ')'); + end = strrchr(arg, ')'); if (!end || *(end + 1) != '\0') return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Malformed ConditionFirmware=%s: %m", c->parameter);