aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@openbsd.org>2015-07-20 00:57:53 +0000
committerTed Unangst <tedu@openbsd.org>2015-07-20 00:57:53 +0000
commitcfaba1b73233afafd94b7d75245487e847d77cc4 (patch)
tree62737e5832c36bdd87edbf6fc755150bf8c5d4f7
parent8cd9e5e59f39760e91b8a8413b4ec753954d5b6c (diff)
downloadopendoas-cfaba1b73233afafd94b7d75245487e847d77cc4.tar.gz
rescope and rename some variables to reduce pressure on the alphabet
-rw-r--r--doas.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/doas.c b/doas.c
index 50dbccb..8ba6c96 100644
--- 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--];