diff options
author | Tomas Mraz <tm@t8m.info> | 2008-04-08 08:55:01 +0000 |
---|---|---|
committer | Tomas Mraz <tm@t8m.info> | 2008-04-08 08:55:01 +0000 |
commit | a91cf2c6dd95af8bab7d58f362d732b80d4ba9db (patch) | |
tree | 69cdd500b61ee9eba1a44f4d0bb23c573f713de8 /libpam | |
parent | d69323ff1d1c710667b01e75326b721c73cdedd8 (diff) |
Relevant BUGIDs:
Purpose of commit: bugfix
Commit summary:
---------------
2008-04-08 Tomas Mraz <t8m@centrum.cz>
* libpam/pam_item.c (TRY_SET): Do not set when destination
is identical to source.
(pam_set_item): Do not overwrite destination when it
is identical to source.
Diffstat (limited to 'libpam')
-rw-r--r-- | libpam/pam_item.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/libpam/pam_item.c b/libpam/pam_item.c index 724ea694..f3d794eb 100644 --- a/libpam/pam_item.c +++ b/libpam/pam_item.c @@ -11,13 +11,15 @@ #include <string.h> #include <syslog.h> -#define TRY_SET(X, Y) \ -{ \ - char *_TMP_ = _pam_strdup(Y); \ - if (_TMP_ == NULL && (Y) != NULL) \ - return PAM_BUF_ERR; \ - free(X); \ - (X) = _TMP_; \ +#define TRY_SET(X, Y) \ +{ \ + if ((X) != (Y)) { \ + char *_TMP_ = _pam_strdup(Y); \ + if (_TMP_ == NULL && (Y) != NULL) \ + return PAM_BUF_ERR; \ + free(X); \ + (X) = _TMP_; \ + } \ } /* functions */ @@ -76,8 +78,10 @@ int pam_set_item (pam_handle_t *pamh, int item_type, const void *item) * modules. */ if (__PAM_FROM_MODULE(pamh)) { - _pam_overwrite(pamh->authtok); - TRY_SET(pamh->authtok, item); + if (pamh->authtok != item) { + _pam_overwrite(pamh->authtok); + TRY_SET(pamh->authtok, item); + } } else { retval = PAM_BAD_ITEM; } @@ -90,8 +94,10 @@ int pam_set_item (pam_handle_t *pamh, int item_type, const void *item) * modules. */ if (__PAM_FROM_MODULE(pamh)) { - _pam_overwrite(pamh->oldauthtok); - TRY_SET(pamh->oldauthtok, item); + if (pamh->oldauthtok != item) { + _pam_overwrite(pamh->oldauthtok); + TRY_SET(pamh->oldauthtok, item); + } } else { retval = PAM_BAD_ITEM; } @@ -130,6 +136,8 @@ int pam_set_item (pam_handle_t *pamh, int item_type, const void *item) break; case PAM_XAUTHDATA: + if (&pamh->xauth == item) + break; if (pamh->xauth.namelen) { _pam_overwrite(pamh->xauth.name); free(pamh->xauth.name); |