]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
condition: check for last not first ')' in firmware test expressions
authorLennart Poettering <lennart@poettering.net>
Fri, 26 Aug 2022 08:36:45 +0000 (10:36 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 26 Aug 2022 08:46:37 +0000 (10:46 +0200)
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

index 3a09b493fc3dbbdd773f9f31866bbfa5be99ce61..5c6e383679f5a9d98e983e07c5dad19dd6570875 100644 (file)
@@ -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);