Description: Fix unconditional PATH_MAX usage Fix the unconditional PATH_MAX usage in pam-ck-connector/pam-ck-connector.c by using a variable-length malloc'ed buffer. Author: Pino Toscano Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=552393 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=24738 Last-Update: 2010-09-20 Index: consolekit/pam-ck-connector/pam-ck-connector.c =================================================================== --- consolekit.orig/pam-ck-connector/pam-ck-connector.c 2010-09-20 17:15:53.000000000 +0200 +++ consolekit/pam-ck-connector/pam-ck-connector.c 2010-09-20 17:33:54.000000000 +0200 @@ -244,12 +244,12 @@ const char *s; uid_t uid; char buf[256]; - char ttybuf[PATH_MAX]; + char *ttybuf; DBusError error; dbus_bool_t is_local; ret = PAM_IGNORE; - + ttybuf = NULL; is_local = TRUE; _parse_pam_args (pamh, flags, argc, argv); @@ -295,7 +295,13 @@ x11_display = display_device; display_device = ""; } else if (strncmp (_PATH_DEV, display_device, 5) != 0) { - snprintf (ttybuf, sizeof (ttybuf), _PATH_DEV "%s", display_device); + int len = strlen (_PATH_DEV) + strlen (display_device) + 1; + ttybuf = malloc (len); + if (ttybuf == NULL) { + ck_pam_syslog (pamh, LOG_ERR, "oom allocating ttybuf"); + goto out; + } + snprintf (ttybuf, len, _PATH_DEV "%s", display_device); display_device = ttybuf; } @@ -411,6 +417,8 @@ ret = PAM_SUCCESS; out: + free (ttybuf); + return ret; }