aboutsummaryrefslogtreecommitdiff
path: root/libpamc
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2023-12-15 10:14:11 +0100
committerDmitry V. Levin <ldv@strace.io>2023-12-19 12:22:59 +0000
commitc2fafe1be0fb72aa1bd521efe2f524074bf143c7 (patch)
tree0790beda071109b1c0ef9397d442ff641f7077c9 /libpamc
parent6834e0dd1dcae917caa464d1fe124c2f6c6116f4 (diff)
downloadpam-c2fafe1be0fb72aa1bd521efe2f524074bf143c7.tar.gz
pam-c2fafe1be0fb72aa1bd521efe2f524074bf143c7.tar.bz2
pam-c2fafe1be0fb72aa1bd521efe2f524074bf143c7.zip
treewide: replace malloc followed by strcpy with strdup
Suggested-by: Benny Baumann <BenBE@geshi.org> Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'libpamc')
-rw-r--r--libpamc/pamc_load.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/libpamc/pamc_load.c b/libpamc/pamc_load.c
index cbf4b994..7efd5721 100644
--- a/libpamc/pamc_load.c
+++ b/libpamc/pamc_load.c
@@ -224,14 +224,13 @@ int pamc_disable(pamc_handle_t pch, const char *agent_id)
return PAM_BPC_FALSE;
}
- block->id = malloc(1 + strlen(agent_id));
+ block->id = strdup(agent_id);
if (block->id == NULL) {
D(("no memory for agent id"));
free(block);
return PAM_BPC_FALSE;
}
- strcpy(block->id, agent_id);
block->next = pch->blocked_agents;
pch->blocked_agents = block;
@@ -372,10 +371,8 @@ static pamc_id_node_t *__pamc_add_node(pamc_id_node_t *root, const char *id,
pamc_id_node_t *node = calloc(1, sizeof(pamc_id_node_t));
if (node) {
- node->agent_id = malloc(1+strlen(id));
- if (node->agent_id) {
- strcpy(node->agent_id, id);
- } else {
+ node->agent_id = strdup(id);
+ if (node->agent_id == NULL) {
free(node);
node = NULL;
}