From: Lennart Poettering Date: Fri, 26 Aug 2022 08:36:45 +0000 (+0200) Subject: condition: check for last not first ')' in firmware test expressions X-Git-Tag: v252-rc1~331^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1dc042ae12be9aa0a834eba7747f78079d06fcde;p=thirdparty%2Fsystemd.git 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. --- 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);