summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Mraz <tm@t8m.info>2008-04-08 08:56:32 +0000
committerTomas Mraz <tm@t8m.info>2008-04-08 08:56:32 +0000
commit59b292aeb314ed4f7c14fa2508a421829da81f93 (patch)
tree8bc81547011e0d75f21856aa5e8bb37ed741ac38
parente359d4ad55858b6440f5077d632f14249137add4 (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.
-rw-r--r--ChangeLog5
-rw-r--r--libpam/pam_item.c30
2 files changed, 24 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 00c5a29b..190a538e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,11 @@
* modules/pam_xauth/pam_xauth.c(run_coprocess): Avoid multiple
calls to sysconf() (based on patch by Sami Farin).
+ * 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.
+
2008-04-07 Miloš Komarčević <kmilos@gmail.com>
* po/sr.po: New file with translation.
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);