summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-06-20 12:35:34 +0200
committerGitHub <noreply@github.com>2019-06-20 12:35:34 +0200
commit64ef83139cf84a700b95e8150a458b0bb9f720de (patch)
treed824cbcedcdcddae04c7aebc0b5ecadcb5122d5b /src/journal
parent0219b3524f414e23589e63c6de6a759811ef8474 (diff)
parent31a9be2372eeef7357dc8c2fd95b1e96305c107d (diff)
downloadsystemd-64ef83139cf84a700b95e8150a458b0bb9f720de.tar.gz
systemd-64ef83139cf84a700b95e8150a458b0bb9f720de.tar.bz2
systemd-64ef83139cf84a700b95e8150a458b0bb9f720de.zip
Merge pull request #12837 from yuwata/tree-wide-lgtm-fixes
tree-wide: fix issues found by lgtm
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journalctl.c6
-rw-r--r--src/journal/journald-audit.c7
2 files changed, 9 insertions, 4 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index a3eb61e0f1..27518b6363 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1679,9 +1679,11 @@ static int add_syslog_identifier(sd_journal *j) {
assert(j);
STRV_FOREACH(i, arg_syslog_identifier) {
- char *u;
+ _cleanup_free_ char *u = NULL;
- u = strjoina("SYSLOG_IDENTIFIER=", *i);
+ u = strjoin("SYSLOG_IDENTIFIER=", *i);
+ if (!u)
+ return -ENOMEM;
r = sd_journal_add_match(j, u, 0);
if (r < 0)
return r;
diff --git a/src/journal/journald-audit.c b/src/journal/journald-audit.c
index 71d9282ed5..fae9138ecb 100644
--- a/src/journal/journald-audit.c
+++ b/src/journal/journald-audit.c
@@ -264,8 +264,8 @@ static int map_all_fields(
if (handle_msg) {
v = startswith(p, "msg='");
if (v) {
+ _cleanup_free_ char *c = NULL;
const char *e;
- char *c;
/* Userspace message. It's enclosed in
simple quotation marks, is not
@@ -279,7 +279,10 @@ static int map_all_fields(
if (!e)
return 0; /* don't continue splitting up if the final quotation mark is missing */
- c = strndupa(v, e - v);
+ c = strndup(v, e - v);
+ if (!c)
+ return -ENOMEM;
+
return map_all_fields(c, map_fields_userspace, "AUDIT_FIELD_", false, iov, n_iov_allocated, n_iov);
}
}