]> granicus.if.org Git - linux-pam/commitdiff
Relevant BUGIDs: 483959
authorSteve Langasek <vorlon@debian.org>
Fri, 30 Nov 2001 23:26:30 +0000 (23:26 +0000)
committerSteve Langasek <vorlon@debian.org>
Fri, 30 Nov 2001 23:26:30 +0000 (23:26 +0000)
Purpose of commit: bugfix

Commit summary:
---------------
pam_unix: fix 'likeauth' to kill off the memory leak once and for all.

CHANGELOG
modules/pam_unix/pam_unix_auth.c

index 1e69e29b4b38a40537170f149296308841c814ac..d7630f1a521b6803d98bbd30b1cc37e9a18e19eb 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -49,6 +49,8 @@ bug report - outstanding bugs are listed here:
 0.76: please submit patches for this section with actual code/doc
       patches!
 
+* pam_unix: fix 'likeauth' to kill off the memory leak once and for all.
+  (Bug 483959 - vorlon)
 * pam_unix: restore handling of 'likeauth' argument to a known working
   state; prettify AUTH_RETURN macro; remove redundant argv checks in
   pam_sm_setcred() (Bugs 483959, 113596 - vorlon)
index a42e492669f93ef4c4d9c277df7a02a11060ce6f..319f4f05d19a0cc5c3e4944f46e54ada1f2b2461 100644 (file)
@@ -87,12 +87,20 @@ do {                                                                \
                                        retval));               \
                *ret_data = retval;                             \
                pam_set_data(pamh, "unix_setcred_return",       \
-                               (void *) ret_data, NULL);       \
+                            (void *) ret_data, setcred_free);  \
        }                                                       \
        D(("done. [%s]", pam_strerror(pamh, retval)));          \
        return retval;                                          \
 } while (0)
 
+
+static void setcred_free (pam_handle_t * pamh, void *ptr, int err)
+{
+       if (ptr)
+               free (ptr);
+}
+
+
 PAM_EXTERN int pam_sm_authenticate(pam_handle_t * pamh, int flags
                                   ,int argc, const char **argv)
 {
@@ -198,10 +206,9 @@ PAM_EXTERN int pam_sm_setcred(pam_handle_t * pamh, int flags
        /* We will only find something here if UNIX_LIKE_AUTH is set -- 
           don't worry about an explicit check of argv. */
        pam_get_data(pamh, "unix_setcred_return", (const void **) &pretval);
-       pam_set_data(pamh, "unix_setcred_return", NULL, NULL);
        if(pretval) {
                retval = *pretval;
-               free(pretval);
+               pam_set_data(pamh, "unix_setcred_return", NULL, NULL);
                D(("recovered data indicates that old retval was %d", retval));
        }