From 01cd94b5228ce4f13383212f1e83a758a1c2e9ff Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 13 May 1997 08:22:11 +0000 Subject: Defensive programming in case lexer passes a blank string or null. svn path=/trunk/; revision=990 --- rcfile_y.y | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'rcfile_y.y') diff --git a/rcfile_y.y b/rcfile_y.y index 2b5bd871..d6266d4d 100644 --- a/rcfile_y.y +++ b/rcfile_y.y @@ -240,7 +240,8 @@ static struct query *hosttail; /* where to add new elements */ void yyerror (const char *s) /* report a syntax error */ { - error_at_line( 0, 0, rcfile, prc_lineno, "%s at %s", s, yytext ); + error_at_line( 0, 0, rcfile, prc_lineno, "%s at %s", s, + (yytext && yytext[0]) ? yytext : "end of input"); prc_errflag++; } @@ -250,15 +251,16 @@ const char *pathname; /* pathname for the configuration file */ { struct stat statbuf; - /* special case, useful for debugging purposes */ - if (strcmp("/dev/null", pathname) == 0) + errno = 0; + + /* special cases useful for debugging purposes */ + if (strcmp("/dev/null", pathname) == 0 || versioninfo) return(0); /* the run control file must have the same uid as the REAL uid of this process, it must have permissions no greater than 600, and it must not be a symbolic link. We check these conditions here. */ - errno = 0; if (lstat(pathname, &statbuf) < 0) { if (errno == ENOENT) return(0); -- cgit v1.2.3