-/* $OpenBSD: doas.c,v 1.88 2021/01/21 08:13:59 kn Exp $ */
+/* $OpenBSD: doas.c,v 1.89 2021/01/27 17:02:50 millert Exp $ */
/*
* Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
*
permit(uid_t uid, gid_t *groups, int ngroups, const struct rule **lastr,
uid_t target, const char *cmd, const char **cmdargs)
{
- int i;
+ size_t i;
*lastr = NULL;
for (i = 0; i < nrules; i++) {
-/* $OpenBSD: doas.h,v 1.16 2020/10/09 07:43:38 kn Exp $ */
+/* $OpenBSD: doas.h,v 1.17 2021/01/27 17:02:50 millert Exp $ */
/*
* Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
*
};
extern struct rule **rules;
-extern int nrules;
+extern size_t nrules;
extern int parse_errors;
extern const char *formerpath;
-/* $OpenBSD: parse.y,v 1.28 2020/10/09 07:43:38 kn Exp $ */
+/* $OpenBSD: parse.y,v 1.29 2021/01/27 17:02:50 millert Exp $ */
/*
* Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
*
FILE *yyfp;
struct rule **rules;
-int nrules;
-static int maxrules;
+size_t nrules;
+static size_t maxrules;
int parse_errors = 0;
r->cmdargs = $4.cmdargs;
if (nrules == maxrules) {
if (maxrules == 0)
- maxrules = 63;
- else
- maxrules *= 2;
- if (!(rules = reallocarray(rules, maxrules,
- sizeof(*rules))))
+ maxrules = 32;
+ rules = reallocarray(rules, maxrules,
+ 2 * sizeof(*rules));
+ if (!rules)
errx(1, "can't allocate rules");
+ maxrules *= 2;
}
rules[nrules++] = r;
} ;
yylex(void)
{
char buf[1024], *ebuf, *p, *str;
- int i, c, quotes = 0, escape = 0, qpos = -1, nonkw = 0;
+ int c, quotes = 0, escape = 0, qpos = -1, nonkw = 0;
+ size_t i;
p = buf;
ebuf = buf + sizeof(buf);