diff options
Diffstat (limited to 'modules/pam_exec/pam_exec.c')
-rw-r--r-- | modules/pam_exec/pam_exec.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/modules/pam_exec/pam_exec.c b/modules/pam_exec/pam_exec.c index 9d2145dc..e328be16 100644 --- a/modules/pam_exec/pam_exec.c +++ b/modules/pam_exec/pam_exec.c @@ -33,9 +33,7 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if defined(HAVE_CONFIG_H) #include "config.h" -#endif #include <time.h> #include <errno.h> @@ -55,6 +53,7 @@ #include <security/pam_ext.h> #include <security/_pam_macros.h> #include "pam_inline.h" +#include "pam_i18n.h" #define ENV_ITEM(n) { (n), #n } static struct { @@ -156,7 +155,7 @@ call_exec (const char *pam_type, pam_handle_t *pamh, if (expose_authtok == 1) { - if (strcmp (pam_type, "auth") != 0) + if (strcmp (pam_type, "auth") != 0 && strcmp (pam_type, "password") != 0) { pam_syslog (pamh, LOG_ERR, "expose_authtok not supported for type %s", pam_type); @@ -268,16 +267,15 @@ call_exec (const char *pam_type, pam_handle_t *pamh, if (use_stdout) { - char buf[4096]; + char *buf = NULL; + size_t n = 0; close(stdout_fds[1]); - while (fgets(buf, sizeof(buf), stdout_file) != NULL) + while (getline(&buf, &n, stdout_file) != -1) { - size_t len; - len = strlen(buf); - if (buf[len-1] == '\n') - buf[len-1] = '\0'; + buf[strcspn(buf, "\n")] = '\0'; pam_info(pamh, "%s", buf); } + free(buf); fclose(stdout_file); } @@ -436,7 +434,7 @@ call_exec (const char *pam_type, pam_handle_t *pamh, _exit (err); } - arggv = calloc (argc + 4, sizeof (char *)); + arggv = calloc ((size_t) argc + 1, sizeof (char *)); if (arggv == NULL) _exit (ENOMEM); |