Initialize tmp to NULL so that items can be cleared as intended.
Don't forget to fill the pam_conv structure after allocating it. Sponsored by: DARPA, NAI Labs git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@55 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
parent
a9a4681bc5
commit
39a1582d7e
|
@ -62,6 +62,7 @@ pam_set_item(pam_handle_t *pamh,
|
|||
return (PAM_SYSTEM_ERR);
|
||||
|
||||
slot = &pamh->item[item_type];
|
||||
tmp = NULL;
|
||||
switch (item_type) {
|
||||
case PAM_SERVICE:
|
||||
case PAM_USER:
|
||||
|
@ -75,18 +76,20 @@ pam_set_item(pam_handle_t *pamh,
|
|||
if (*slot != NULL)
|
||||
size = strlen(*slot) + 1;
|
||||
if (item != NULL)
|
||||
tmp = strdup(item);
|
||||
if ((tmp = strdup(item)) == NULL)
|
||||
return (PAM_BUF_ERR);
|
||||
break;
|
||||
case PAM_CONV:
|
||||
size = sizeof(struct pam_conv);
|
||||
if (item != NULL)
|
||||
tmp = malloc(size);
|
||||
if (item != NULL) {
|
||||
if ((tmp = malloc(size)) == NULL)
|
||||
return (PAM_BUF_ERR);
|
||||
memcpy(tmp, item, sizeof(struct pam_conv));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return (PAM_SYSTEM_ERR);
|
||||
}
|
||||
if (item != NULL && tmp == NULL)
|
||||
return (PAM_BUF_ERR);
|
||||
if (*slot != NULL) {
|
||||
memset(*slot, 0xd0, size);
|
||||
free(*slot);
|
||||
|
|
Loading…
Reference in New Issue