Merge pull request #16238 from keszybz/set-handling-more

Fix handling of cases where a duplicate item is added to a set and related cleanups
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2020-06-24 17:42:13 +02:00
committed by GitHub
46 changed files with 276 additions and 504 deletions
+1 -5
View File
@@ -613,13 +613,9 @@ int bus_message_print_all_properties(
return r;
if (found_properties) {
r = set_ensure_allocated(found_properties, &string_hash_ops);
r = set_ensure_put(found_properties, &string_hash_ops, name);
if (r < 0)
return log_oom();
r = set_put(*found_properties, name);
if (r < 0 && r != -EEXIST)
return log_oom();
}
name_with_equal = strjoin(name, "=");
+5 -10
View File
@@ -1742,17 +1742,13 @@ int seccomp_restrict_archs(Set *archs) {
return 0;
}
int parse_syscall_archs(char **l, Set **archs) {
_cleanup_set_free_ Set *_archs = NULL;
int parse_syscall_archs(char **l, Set **ret_archs) {
_cleanup_set_free_ Set *archs = NULL;
char **s;
int r;
assert(l);
assert(archs);
r = set_ensure_allocated(&_archs, NULL);
if (r < 0)
return r;
assert(ret_archs);
STRV_FOREACH(s, l) {
uint32_t a;
@@ -1761,13 +1757,12 @@ int parse_syscall_archs(char **l, Set **archs) {
if (r < 0)
return -EINVAL;
r = set_put(_archs, UINT32_TO_PTR(a + 1));
r = set_ensure_put(&archs, NULL, UINT32_TO_PTR(a + 1));
if (r < 0)
return -ENOMEM;
}
*archs = TAKE_PTR(_archs);
*ret_archs = TAKE_PTR(archs);
return 0;
}
+1 -1
View File
@@ -105,6 +105,6 @@ extern const uint32_t seccomp_local_archs[];
DEFINE_TRIVIAL_CLEANUP_FUNC(scmp_filter_ctx, seccomp_release);
int parse_syscall_archs(char **l, Set **archs);
int parse_syscall_archs(char **l, Set **ret_archs);
uint32_t scmp_act_kill_process(void);
+1 -7
View File
@@ -377,15 +377,9 @@ static int userdb_connect(
if (r < 0)
return log_debug_errno(r, "Failed to invoke varlink method: %m");
r = set_ensure_allocated(&iterator->links, &link_hash_ops);
if (r < 0)
return log_debug_errno(r, "Failed to allocate set: %m");
r = set_put(iterator->links, vl);
r = set_ensure_consume(&iterator->links, &link_hash_ops, TAKE_PTR(vl));
if (r < 0)
return log_debug_errno(r, "Failed to add varlink connection to set: %m");
TAKE_PTR(vl);
return r;
}