diff options
author | Thorsten Kukuk <kukuk@thkukuk.de> | 2006-12-10 10:37:26 +0000 |
---|---|---|
committer | Thorsten Kukuk <kukuk@thkukuk.de> | 2006-12-10 10:37:26 +0000 |
commit | e648517eef968b1630f0e3cc0dd90a926868b28f (patch) | |
tree | 502ee125e6935bfa9bc7f13692290e47860ea175 | |
parent | 98822a2108d900a59f22f2dc0783e825a1a4de3d (diff) | |
download | pam-e648517eef968b1630f0e3cc0dd90a926868b28f.tar.gz pam-e648517eef968b1630f0e3cc0dd90a926868b28f.tar.bz2 pam-e648517eef968b1630f0e3cc0dd90a926868b28f.zip |
Relevant BUGIDs:
Purpose of commit: bugfix
Commit summary:
---------------
2006-12-09 Thorsten Kukuk <kukuk@thkukuk.de>
* modules/pam_umask/pam_umask.c: Use strtoul instead of strtol,
fix overflow detection.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | modules/pam_umask/pam_umask.c | 23 |
2 files changed, 19 insertions, 9 deletions
@@ -1,3 +1,8 @@ +2006-12-09 Thorsten Kukuk <kukuk@thkukuk.de> + + * modules/pam_umask/pam_umask.c: Use strtoul instead of strtol, + fix overflow detection. + 2006-12-06 Thorsten Kukuk <kukuk@thkukuk.de> * modules/pam_mkhomedir/pam_mkhomedir.c (rec_mkdir): Fix diff --git a/modules/pam_umask/pam_umask.c b/modules/pam_umask/pam_umask.c index c5fa773b..fdeb3c51 100644 --- a/modules/pam_umask/pam_umask.c +++ b/modules/pam_umask/pam_umask.c @@ -15,8 +15,8 @@ * written permission. * * ALTERNATIVELY, this product may be distributed under the terms of - * the GNU Public License, in which case the provisions of the GPL are - * required INSTEAD OF the above restrictions. (This clause is + * the GNU Public License V2, in which case the provisions of the GPL + * are required INSTEAD OF the above restrictions. (This clause is * necessary due to a potential bad interaction between the GPL and * the restrictions contained in a BSD-style copyright.) * @@ -40,6 +40,7 @@ #include <stdio.h> #include <ctype.h> #include <errno.h> +#include <limits.h> #include <string.h> #include <stdarg.h> #include <unistd.h> @@ -55,6 +56,10 @@ #include <security/pam_modutil.h> #include <security/pam_ext.h> +#define BUF_SIZE 4096 +#define LOGIN_DEFS "/etc/login.defs" +#define LOGIN_CONF "/etc/default/login" + struct options_t { int debug; int usergroups; @@ -105,7 +110,7 @@ search_key (const char *filename) if (buf == NULL) { - buflen = 8096; + buflen = BUF_SIZE; buf = malloc (buflen); } buf[0] = '\0'; @@ -145,8 +150,7 @@ search_key (const char *filename) } fclose (fp); - if (buf) - free (buf); + free (buf); return retval; } @@ -161,9 +165,9 @@ get_options (const pam_handle_t *pamh, options_t *options, parse_option (pamh, *argv, options); if (options->umask == NULL) - options->umask = search_key ("/etc/login.defs"); + options->umask = search_key (LOGIN_DEFS); if (options->umask == NULL) - options->umask = search_key ("/etc/default/login"); + options->umask = search_key (LOGIN_CONF); return 0; } @@ -175,8 +179,9 @@ set_umask (const char *value) mode_t mask; char *endptr; - mask = strtol (value, &endptr, 8) & 0777; - if ((mask == 0) && (value_orig == endptr)) + mask = strtoul (value, &endptr, 8) & 0777; + if (((mask == 0) && (value_orig == endptr)) || + ((mask == ULONG_MAX) && (errno == ERANGE))) return; umask (mask); return; |