mirror of
https://github.com/topjohnwu/selinux.git
synced 2024-11-30 06:50:41 +00:00
libsepol: simplify string copying
Use strdup(3) instead of allocating memory and then manually copying the content. Signed-off-by: Christian Göttsche <cgzones@googlemail.com> Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
aaaed69911
commit
06df377829
@ -776,12 +776,11 @@ static int roles_init(policydb_t * p)
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
key = malloc(strlen(OBJECT_R) + 1);
|
||||
key = strdup(OBJECT_R);
|
||||
if (!key) {
|
||||
rc = -ENOMEM;
|
||||
goto out_free_role;
|
||||
}
|
||||
strcpy(key, OBJECT_R);
|
||||
rc = symtab_insert(p, SYM_ROLES, key, role,
|
||||
(p->policy_type ==
|
||||
POLICY_MOD ? SCOPE_REQ : SCOPE_DECL), 1,
|
||||
|
Loading…
Reference in New Issue
Block a user