Message ID | 20221109200939.62525-3-cgzones@googlemail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 06df37782955 |
Headers | show |
Series | [1/3] libselinux: simplify string copying | expand |
diff --git a/libsepol/src/policydb.c b/libsepol/src/policydb.c index 8a65df05..b79c19b9 100644 --- a/libsepol/src/policydb.c +++ b/libsepol/src/policydb.c @@ -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,
Use strdup(3) instead of allocating memory and then manually copying the content. Signed-off-by: Christian Göttsche <cgzones@googlemail.com> --- libsepol/src/policydb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)