Skip to content

Commit

Permalink
selinux: use kstrdup() in security_get_bools()
Browse files Browse the repository at this point in the history
This is much simpler.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <pmoore@redhat.com>
  • Loading branch information
Rasmus Villemoes authored and Paul Moore committed Oct 21, 2015
1 parent aa736c3 commit 21b76f1
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -2609,18 +2609,12 @@ int security_get_bools(int *len, char ***names, int **values)
goto err;

for (i = 0; i < *len; i++) {
size_t name_len;

(*values)[i] = policydb.bool_val_to_struct[i]->state;
name_len = strlen(sym_name(&policydb, SYM_BOOLS, i)) + 1;

rc = -ENOMEM;
(*names)[i] = kmalloc(sizeof(char) * name_len, GFP_ATOMIC);
(*names)[i] = kstrdup(sym_name(&policydb, SYM_BOOLS, i), GFP_ATOMIC);
if (!(*names)[i])
goto err;

strncpy((*names)[i], sym_name(&policydb, SYM_BOOLS, i), name_len);
(*names)[i][name_len - 1] = 0;
}
rc = 0;
out:
Expand Down

0 comments on commit 21b76f1

Please sign in to comment.