sd-journal: don't treat invalid match as a programming error
authorFrantisek Sumsal <frantisek@sumsal.cz>
Wed, 15 Nov 2023 12:38:02 +0000 (13:38 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Wed, 15 Nov 2023 12:38:02 +0000 (13:38 +0100)
Don't use assert_runtime() when we get an invalid match string, since
that's a runtime error:

$ SYSTEMD_LOG_LEVEL=debug coredumpctl info =
...
Adding match: =
Assertion 'match_is_valid(data, size)' failed at src/libsystemd/sd-journal/sd-journal.c:240, function sd_journal_add_match(). Ignoring.
Failed to add match "=": Invalid argument

src/libsystemd/sd-journal/sd-journal.c

index 73a65da..eb35b9d 100644 (file)
@@ -235,7 +235,8 @@ _public_ int sd_journal_add_match(sd_journal *j, const void *data, size_t size)
         if (size == 0)
                 size = strlen(data);
 
-        assert_return(match_is_valid(data, size), -EINVAL);
+        if (!match_is_valid(data, size))
+                return -EINVAL;
 
         /* level 0: AND term
          * level 1: OR terms