summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2018-03-19 00:06:44 +0300
committerGitHub <noreply@github.com>2018-03-19 00:06:44 +0300
commite4711004d611493ff35631d66c6d06bf1e799659 (patch)
tree32e8d9eb389e7880b8705c12b7ae548902d03903 /src/core
parent1e35c5ab27f3a3cf6ae037c62fc1576c4798b576 (diff)
parentca8700e922e280beeb3c5f37a967c21739da0f25 (diff)
downloadsystemd-e4711004d611493ff35631d66c6d06bf1e799659.tar.gz
Merge pull request #8461 from keszybz/oss-fuzz-fixes
Oss fuzz fixes
Diffstat (limited to 'src/core')
-rw-r--r--src/core/service.c3
-rw-r--r--src/core/unit.c31
2 files changed, 16 insertions, 18 deletions
diff --git a/src/core/service.c b/src/core/service.c
index df36019f62..23a5bcd1c4 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -396,6 +396,9 @@ static void service_done(Unit *u) {
s->bus_name_owner = mfree(s->bus_name_owner);
+ s->usb_function_descriptors = mfree(s->usb_function_descriptors);
+ s->usb_function_strings = mfree(s->usb_function_strings);
+
service_close_socket_fd(s);
s->peer = socket_peer_unref(s->peer);
diff --git a/src/core/unit.c b/src/core/unit.c
index f88aabba61..cb45dc290a 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -4564,7 +4564,8 @@ int unit_kill_context(
}
int unit_require_mounts_for(Unit *u, const char *path, UnitDependencyMask mask) {
- char prefix[strlen(path) + 1], *p;
+ _cleanup_free_ char *p = NULL;
+ char *prefix;
UnitDependencyInfo di;
int r;
@@ -4587,34 +4588,30 @@ int unit_require_mounts_for(Unit *u, const char *path, UnitDependencyMask mask)
if (!p)
return -ENOMEM;
- path_kill_slashes(p);
+ path = path_kill_slashes(p);
- if (!path_is_normalized(p)) {
- free(p);
+ if (!path_is_normalized(path))
return -EPERM;
- }
- if (hashmap_contains(u->requires_mounts_for, p)) {
- free(p);
+ if (hashmap_contains(u->requires_mounts_for, path))
return 0;
- }
di = (UnitDependencyInfo) {
.origin_mask = mask
};
- r = hashmap_put(u->requires_mounts_for, p, di.data);
- if (r < 0) {
- free(p);
+ r = hashmap_put(u->requires_mounts_for, path, di.data);
+ if (r < 0)
return r;
- }
+ p = NULL;
- PATH_FOREACH_PREFIX_MORE(prefix, p) {
+ prefix = alloca(strlen(path) + 1);
+ PATH_FOREACH_PREFIX_MORE(prefix, path) {
Set *x;
x = hashmap_get(u->manager->units_requiring_mounts_for, prefix);
if (!x) {
- char *q;
+ _cleanup_free_ char *q = NULL;
r = hashmap_ensure_allocated(&u->manager->units_requiring_mounts_for, &path_hash_ops);
if (r < 0)
@@ -4625,17 +4622,15 @@ int unit_require_mounts_for(Unit *u, const char *path, UnitDependencyMask mask)
return -ENOMEM;
x = set_new(NULL);
- if (!x) {
- free(q);
+ if (!x)
return -ENOMEM;
- }
r = hashmap_put(u->manager->units_requiring_mounts_for, q, x);
if (r < 0) {
- free(q);
set_free(x);
return r;
}
+ q = NULL;
}
r = set_put(x, u);