* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
*
* Change Log:
+ * 2010-02-24 hno
+ * Removed group number limitation and fixed related uninitialized
+ * pointer reference (Bug #2813)
+ *
* Revision 1.7 2004/08/15 00:29:33 hno
* helper protocol changed to URL-escaped strings in Squid-3.0
*
#include <ctype.h>
#define BUFSIZE 8192 /* the stdin buffer size */
-#define MAX_GROUP 10 /* maximum number of groups specified
-* on the command line */
/*
* Verify if user“s primary group matches groupname
{
char *user, *suser, *p;
char buf[BUFSIZE];
- char *grents[MAX_GROUP];
- int check_pw = 0, ch, i = 0, j = 0, strip_dm = 0;
+ char **grents = NULL;
+ int check_pw = 0, ch, ngroups = 0, i, j = 0, strip_dm = 0;
/* make standard output line buffered */
setvbuf(stdout, NULL, _IOLBF, 0);
check_pw = 1;
break;
case 'g':
- grents[i] = calloc(strlen(optarg) + 1, sizeof(char));
- strcpy(grents[i], optarg);
- if (i < MAX_GROUP) {
- i++;
- } else {
- fprintf(stderr,
- "Exceeded maximum number of allowed groups (%i)\n", i);
- exit(1);
- }
+ grents = realloc(grents, sizeof(*grents) * (ngroups+1));
+ grents[ngroups++] = optarg;
break;
case '?':
if (xisprint(optopt)) {
-
fprintf(stderr, "Unknown option '-%c'.\n", optopt);
} else {
fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
rfc1738_unescape(p);
if (check_pw == 1)
j += validate_user_pw(user, p);
-
j += validate_user_gr(user, p);
}
}
/* check groups supplied on the command line */
- for (i = 0; grents[i] != NULL; i++) {
+ for (i = 0; i < ngroups; i++) {
if (check_pw == 1) {
j += validate_user_pw(user, grents[i]);
}