]> granicus.if.org Git - linux-pam/commitdiff
Relevant BUGIDs:
authorTomas Mraz <tm@t8m.info>
Tue, 8 Apr 2008 08:55:01 +0000 (08:55 +0000)
committerTomas Mraz <tm@t8m.info>
Tue, 8 Apr 2008 08:55:01 +0000 (08:55 +0000)
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.

ChangeLog
libpam/pam_item.c

index 214852106119aed6a98f4650088d404915170865..bb34a20b5e209871686c39c9116226f57cefcc2e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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.
+
 2008-04-07  Miloš Komarčević <kmilos@gmail.com>
 
        * po/sr.po: New file with translation.
index 724ea69428dea42d0dd9358b054e5e879965e2f9..f3d794ebfb0e81bad346fa48f4905710c6fec3f3 100644 (file)
 #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);