stun

simple point to point tunnel
git clone git://git.2f30.org/stun.git
Log | Files | Refs | README

commit 302fc0ed720e06adbb1793ed172b0565b2807c53
parent 95eafa851e90d34565e7005776c339ab525d45fc
Author: sin <sin@2f30.org>
Date:   Wed Apr 27 22:58:10 +0100

Move config file permission check to pushfile()

Diffstat:
parse.y | 19++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/parse.y b/parse.y @@ -95,15 +95,8 @@ optnl_l : ; include : INCLUDE STRING { - struct stat sb; struct file *nfile; - if (stat($2, &sb) == 0 && sb.st_mode & 007) { - yyerror("%s: shouldn't be readable by others", $2); - free($2); - YYERROR; - } - if (!(nfile = pushfile($2))) { yyerror("failed to include %s", $2); free($2); @@ -543,8 +536,14 @@ nodigits: static struct file * pushfile(const char *name) { + struct stat sb; struct file *nfile; + if (stat(name, &sb) == 0 && sb.st_mode & 007) { + logerrx("%s: shouldn't be readable by others", name); + return NULL; + } + if (!(nfile = calloc(1, sizeof(struct file)))) return NULL; if (!(nfile->name = strdup(name))) { @@ -591,18 +590,12 @@ resetnetconfig(struct netcfg *np) int parseconf(const char *filename) { - struct stat sb; struct netcfg *np; int errors = 0; TAILQ_INIT(&netcfgs); resetnetconfig(&curnet); - if (stat(filename, &sb) == 0 && sb.st_mode & 007) { - logerrx("%s: shouldn't be readable by others", filename); - return -1; - } - if (!(file = pushfile(filename))) return -1; topfile = file;