From: Zbigniew Jędrzejewski-Szmek Date: Thu, 10 Jan 2019 08:53:34 +0000 (+0100) Subject: pam_systemd: do no allocate the path of fixed length X-Git-Tag: v241-rc1~51^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=055c08ef67c4b2295a185f927dc8d76af3a8deef;p=thirdparty%2Fsystemd.git pam_systemd: do no allocate the path of fixed length --- diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c index d466e509690..a33d8f05c50 100644 --- a/src/login/pam_systemd.c +++ b/src/login/pam_systemd.c @@ -28,6 +28,7 @@ #include "path-util.h" #include "process-util.h" #include "socket-util.h" +#include "stdio-util.h" #include "strv.h" #include "terminal-util.h" #include "util.h" @@ -414,11 +415,9 @@ _public_ PAM_EXTERN int pam_sm_open_session( pam_get_item(handle, PAM_SERVICE, (const void**) &service); if (streq_ptr(service, "systemd-user")) { - _cleanup_free_ char *rt = NULL; - - if (asprintf(&rt, "/run/user/"UID_FMT, pw->pw_uid) < 0) - return PAM_BUF_ERR; + char rt[STRLEN("/run/user/") + DECIMAL_STR_MAX(uid_t)]; + xsprintf(rt, "/run/user/"UID_FMT, pw->pw_uid); if (validate_runtime_directory(handle, rt, pw->pw_uid)) { r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", rt, 0); if (r != PAM_SUCCESS) {