summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/bus-get-properties.c2
-rw-r--r--src/shared/bus-unit-procs.c2
-rw-r--r--src/shared/bus-unit-util.c10
-rw-r--r--src/shared/dns-domain.c4
-rw-r--r--src/shared/journal-importer.c4
-rw-r--r--src/shared/logs-show.c4
-rw-r--r--src/shared/pager.c4
-rw-r--r--src/shared/selinux-util.c3
-rw-r--r--src/shared/tpm2-util.c2
-rw-r--r--src/shared/uid-range.c2
10 files changed, 19 insertions, 18 deletions
diff --git a/src/shared/bus-get-properties.c b/src/shared/bus-get-properties.c
index feb6d3807f..8b4f66b22e 100644
--- a/src/shared/bus-get-properties.c
+++ b/src/shared/bus-get-properties.c
@@ -130,7 +130,7 @@ int bus_property_get_rlimit(
int z;
/* Chop off "Soft" suffix */
- s = is_soft ? strndupa(property, is_soft - property) : property;
+ s = is_soft ? strndupa_safe(property, is_soft - property) : property;
/* Skip over any prefix, such as "Default" */
assert_se(p = strstr(s, "Limit"));
diff --git a/src/shared/bus-unit-procs.c b/src/shared/bus-unit-procs.c
index 3bdcba325f..50deb9252e 100644
--- a/src/shared/bus-unit-procs.c
+++ b/src/shared/bus-unit-procs.c
@@ -46,7 +46,7 @@ static int add_cgroup(Hashmap *cgroups, const char *path, bool is_const, struct
if (!e)
return -EINVAL;
- pp = strndupa(path, e - path);
+ pp = strndupa_safe(path, e - path);
r = add_cgroup(cgroups, pp, false, &parent);
if (r < 0)
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
index 8b81e8058b..7df1e0b310 100644
--- a/src/shared/bus-unit-util.c
+++ b/src/shared/bus-unit-util.c
@@ -605,7 +605,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
e = strchr(eq, ' ');
if (e) {
- path = strndupa(eq, e - eq);
+ path = strndupa_safe(eq, e - eq);
rwm = e+1;
}
@@ -631,7 +631,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
"Failed to parse %s value %s.",
field, eq);
- path = strndupa(eq, e - eq);
+ path = strndupa_safe(eq, e - eq);
bandwidth = e+1;
if (streq(bandwidth, "infinity"))
@@ -665,7 +665,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
"Failed to parse %s value %s.",
field, eq);
- path = strndupa(eq, e - eq);
+ path = strndupa_safe(eq, e - eq);
weight = e+1;
r = safe_atou64(weight, &u);
@@ -696,7 +696,7 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
"Failed to parse %s value %s.",
field, eq);
- path = strndupa(eq, e - eq);
+ path = strndupa_safe(eq, e - eq);
target = e+1;
r = parse_sec(target, &usec);
@@ -2402,7 +2402,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, UnitType t, const cha
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Not an assignment: %s", assignment);
- field = strndupa(assignment, eq - assignment);
+ field = strndupa_safe(assignment, eq - assignment);
eq++;
switch (t) {
diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c
index 787bb8fec9..f54b187a1b 100644
--- a/src/shared/dns-domain.c
+++ b/src/shared/dns-domain.c
@@ -680,7 +680,7 @@ int dns_name_change_suffix(const char *name, const char *old_suffix, const char
}
/* Found it! Now generate the new name */
- prefix = strndupa(name, saved_before - name);
+ prefix = strndupa_safe(name, saved_before - name);
r = dns_name_concat(prefix, new_suffix, 0, ret);
if (r < 0)
@@ -1028,7 +1028,7 @@ static bool dns_service_name_label_is_valid(const char *label, size_t n) {
if (memchr(label, 0, n))
return false;
- s = strndupa(label, n);
+ s = strndupa_safe(label, n);
return dns_service_name_is_valid(s);
}
diff --git a/src/shared/journal-importer.c b/src/shared/journal-importer.c
index bbb152481e..c6caf9330a 100644
--- a/src/shared/journal-importer.c
+++ b/src/shared/journal-importer.c
@@ -316,7 +316,7 @@ int journal_importer_process_data(JournalImporter *imp) {
if (!journal_field_valid(line, sep - line, true)) {
char buf[64], *t;
- t = strndupa(line, sep - line);
+ t = strndupa_safe(line, sep - line);
log_debug("Ignoring invalid field: \"%s\"",
cellescape(buf, sizeof buf, t));
@@ -335,7 +335,7 @@ int journal_importer_process_data(JournalImporter *imp) {
if (!journal_field_valid(line, n - 1, true)) {
char buf[64], *t;
- t = strndupa(line, n - 1);
+ t = strndupa_safe(line, n - 1);
log_debug("Ignoring invalid field: \"%s\"",
cellescape(buf, sizeof buf, t));
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 75fe4f34f7..cf83eb6bca 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -190,7 +190,7 @@ static int field_set_test(const Set *fields, const char *name, size_t n) {
if (!fields)
return 1;
- s = strndupa(name, n);
+ s = strndupa_safe(name, n);
return set_contains(fields, s);
}
@@ -972,7 +972,7 @@ static int update_json_data_split(
if (!journal_field_valid(data, fieldlen, true))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid field.");
- name = strndupa(data, fieldlen);
+ name = strndupa_safe(data, fieldlen);
if (output_fields && !set_contains(output_fields, name))
return 0;
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 4bbad7e37b..90c347f8c0 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -309,8 +309,8 @@ int show_man_page(const char *desc, bool null_stdio) {
if (e) {
char *page = NULL, *section = NULL;
- page = strndupa(desc, e - desc);
- section = strndupa(e + 1, desc + k - e - 2);
+ page = strndupa_safe(desc, e - desc);
+ section = strndupa_safe(e + 1, desc + k - e - 2);
args[1] = section;
args[2] = page;
diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c
index ca92a65efc..da43fa22b9 100644
--- a/src/shared/selinux-util.c
+++ b/src/shared/selinux-util.c
@@ -647,7 +647,8 @@ int mac_selinux_bind(int fd, const struct sockaddr *addr, socklen_t addrlen) {
if (un->sun_path[0] == 0)
goto skipped;
- path = strndupa(un->sun_path, addrlen - offsetof(struct sockaddr_un, sun_path));
+ path = strndupa_safe(un->sun_path,
+ addrlen - offsetof(struct sockaddr_un, sun_path));
/* Check for policy reload so 'label_hnd' is kept up-to-date by callbacks */
mac_selinux_maybe_reload();
diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c
index 9d5a0ed865..6a84d23db6 100644
--- a/src/shared/tpm2-util.c
+++ b/src/shared/tpm2-util.c
@@ -151,7 +151,7 @@ static int tpm2_init(const char *device, struct tpm2_context *ret) {
param = strchr(device, ':');
if (param) {
- driver = strndupa(device, param - device);
+ driver = strndupa_safe(device, param - device);
param++;
} else {
driver = "device";
diff --git a/src/shared/uid-range.c b/src/shared/uid-range.c
index 5d5bf7f21d..2c07a1b7a8 100644
--- a/src/shared/uid-range.c
+++ b/src/shared/uid-range.c
@@ -114,7 +114,7 @@ int uid_range_add_str(UidRange **p, unsigned *n, const char *s) {
char *b;
uid_t end;
- b = strndupa(s, t - s);
+ b = strndupa_safe(s, t - s);
r = parse_uid(b, &start);
if (r < 0)
return r;