]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
suL fix use after free on error
authorKarel Zak <kzak@redhat.com>
Tue, 30 Apr 2024 08:51:50 +0000 (10:51 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 2 May 2024 08:56:26 +0000 (10:56 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/su-common.c

index 9bc02319619c8742c2f18d97ae8b21ded0666c05..3dda84e532ba9ccfe8f8bc10d551ab6a7ee6f76e 100644 (file)
@@ -447,9 +447,10 @@ static void supam_open_session(struct su_context *su)
 
        rc = pam_open_session(su->pamh, 0);
        if (is_pam_failure(rc)) {
+               const char *msg = pam_strerror(su->pamh, rc);
+
                supam_cleanup(su, rc);
-               errx(EXIT_FAILURE, _("cannot open session: %s"),
-                    pam_strerror(su->pamh, rc));
+               errx(EXIT_FAILURE, _("cannot open session: %s"), msg);
        } else
                su->pam_has_session = 1;
 }