diff options
author | Pino Toscano <pino@kde.org> | 2012-03-19 16:46:29 +0100 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2012-03-19 16:46:29 +0100 |
commit | 4d06b16b69f8e9323ce128c92db4bb3e99cbd3aa (patch) | |
tree | e84b71e1b99a318d2cf1c58fdbbebe4f77ca11a3 | |
parent | e722b11a8240991b57bc4f5269c4f375fb6d29af (diff) |
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.
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=552393
https://bugs.freedesktop.org/show_bug.cgi?id=24738
-rw-r--r-- | pam-ck-connector/pam-ck-connector.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/pam-ck-connector/pam-ck-connector.c b/pam-ck-connector/pam-ck-connector.c index 9bdef51..949a9b0 100644 --- a/pam-ck-connector/pam-ck-connector.c +++ b/pam-ck-connector/pam-ck-connector.c @@ -244,12 +244,12 @@ pam_sm_open_session (pam_handle_t *pamh, 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 @@ pam_sm_open_session (pam_handle_t *pamh, 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 @@ pam_sm_open_session (pam_handle_t *pamh, ret = PAM_SUCCESS; out: + free (ttybuf); + return ret; } |