opendoas

A portable version of the OpenBSD `doas` command
git clone https://pi.duncano.de/git/opendoas.git
Log | Files | Refs | README | LICENSE

commit cfaba1b73233afafd94b7d75245487e847d77cc4
parent 8cd9e5e59f39760e91b8a8413b4ec753954d5b6c
Author: Ted Unangst <tedu@openbsd.org>
Date:   Mon, 20 Jul 2015 00:57:53 +0000

rescope and rename some variables to reduce pressure on the alphabet

Diffstat:
doas.c | 21++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/doas.c b/doas.c @@ -1,4 +1,4 @@ -/* $OpenBSD: doas.c,v 1.10 2015/07/19 01:19:22 tedu Exp $ */ +/* $OpenBSD: doas.c,v 1.11 2015/07/20 00:54:01 tedu Exp $ */ /* * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org> * @@ -199,24 +199,25 @@ copyenv(const char **oldenvp, struct rule *rule) char **envp; const char **extra; int ei; - int i, ii, j, jj; int nsafe, nbad; int nextras = 0; nbad = arraylen(badset); if ((rule->options & KEEPENV) && !rule->envlist) { - j = arraylen(oldenvp); - envp = reallocarray(NULL, j + 1, sizeof(char *)); + size_t i, ii; + size_t oldlen = arraylen(oldenvp); + envp = reallocarray(NULL, oldlen + 1, sizeof(char *)); if (!envp) err(1, "reallocarray"); - for (ii = i = 0; i < j; i++) { - for (jj = 0; jj < nbad; jj++) { - size_t len = strlen(badset[jj]); - if (strncmp(oldenvp[i], badset[jj], len) == 0) { + for (ii = i = 0; i < oldlen; i++) { + size_t j; + for (j = 0; j < nbad; j++) { + size_t len = strlen(badset[j]); + if (strncmp(oldenvp[i], badset[j], len) == 0) { break; } } - if (jj == nbad) { + if (j == nbad) { if (!(envp[ii] = strdup(oldenvp[i]))) err(1, "strdup"); ii++; @@ -228,8 +229,10 @@ copyenv(const char **oldenvp, struct rule *rule) nsafe = arraylen(safeset); if ((extra = rule->envlist)) { + size_t i; nextras = arraylen(extra); for (i = 0; i < nsafe; i++) { + size_t j; for (j = 0; j < nextras; j++) { if (strcmp(extra[j], safeset[i]) == 0) { extra[j--] = extra[nextras--];