--- ray/src/common/header.c 2019/05/25 04:00:54 2.33 +++ ray/src/common/header.c 2019/07/19 17:37:56 2.35 @@ -1,10 +1,10 @@ #ifndef lint -static const char RCSid[] = "$Id: header.c,v 2.33 2019/05/25 04:00:54 greg Exp $"; +static const char RCSid[] = "$Id: header.c,v 2.35 2019/07/19 17:37:56 greg Exp $"; #endif /* * header.c - routines for reading and writing information headers. * - * Externals declared in resolu.h + * Externals declared in rtio.h * * newheader(t,fp) start new information header identified by string t * headidval(r,s) copy header identifier value in s to r @@ -210,13 +210,17 @@ getheader( /* get header from file */ { int rtotal = 0; char buf[MAXLINE]; + int firstc = fgetc(fp); + if (!isprint(firstc)) + return(-1); /* messed up */ + ungetc(firstc, fp); for ( ; ; ) { int rval = 0; buf[MAXLINE-2] = '\n'; if (fgets(buf, MAXLINE, fp) == NULL) return(-1); - if (buf[buf[0]=='\r'] == '\n') + if (buf[buf[0]=='\r'] == '\n') /* end of header? */ return(rtotal); if (buf[MAXLINE-2] != '\n') { ungetc(buf[MAXLINE-2], fp); /* prevent false end */