Fix a bug that prevented the service name from being freed, thus
leaking a small amount of memory for every PAM session. While there, eliminate an unnecessary variable. git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@918 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
parent
2f340d61b5
commit
d9e44d146f
|
@ -60,7 +60,7 @@ pam_set_item(pam_handle_t *pamh,
|
||||||
int item_type,
|
int item_type,
|
||||||
const void *item)
|
const void *item)
|
||||||
{
|
{
|
||||||
void **slot, *tmp;
|
void **slot;
|
||||||
size_t nsize, osize;
|
size_t nsize, osize;
|
||||||
|
|
||||||
ENTERI(item_type);
|
ENTERI(item_type);
|
||||||
|
@ -69,7 +69,7 @@ pam_set_item(pam_handle_t *pamh,
|
||||||
switch (item_type) {
|
switch (item_type) {
|
||||||
case PAM_SERVICE:
|
case PAM_SERVICE:
|
||||||
/* set once only, by pam_start() */
|
/* set once only, by pam_start() */
|
||||||
if (*slot != NULL)
|
if (*slot != NULL && item != NULL)
|
||||||
RETURNC(PAM_SYSTEM_ERR);
|
RETURNC(PAM_SYSTEM_ERR);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case PAM_USER:
|
case PAM_USER:
|
||||||
|
@ -101,13 +101,12 @@ pam_set_item(pam_handle_t *pamh,
|
||||||
FREE(*slot);
|
FREE(*slot);
|
||||||
}
|
}
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
if ((tmp = malloc(nsize)) == NULL)
|
if ((*slot = malloc(nsize)) == NULL)
|
||||||
RETURNC(PAM_BUF_ERR);
|
RETURNC(PAM_BUF_ERR);
|
||||||
memcpy(tmp, item, nsize);
|
memcpy(*slot, item, nsize);
|
||||||
} else {
|
} else {
|
||||||
tmp = NULL;
|
*slot = NULL;
|
||||||
}
|
}
|
||||||
*slot = tmp;
|
|
||||||
RETURNC(PAM_SUCCESS);
|
RETURNC(PAM_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue