summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-06-20 06:29:19 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-06-20 06:29:19 +0900
commit6d946490ba835807327b36263c7a3b53653ca762 (patch)
tree09e06ebfbabb1f13fb9faa61314c87f82079e2a0 /src/journal
parentf9dc94408d70dd2f44915f4c6d67dc498c1c6243 (diff)
downloadsystemd-6d946490ba835807327b36263c7a3b53653ca762.tar.gz
systemd-6d946490ba835807327b36263c7a3b53653ca762.tar.bz2
systemd-6d946490ba835807327b36263c7a3b53653ca762.zip
tree-wide: drop alloca() in loop
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 3d053c59f0..d10bced3b7 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1678,9 +1678,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);
}
}