[news.software.b] Bug in fascist

rac@sherpa.UUCP (Roger Cornelius) (04/10/90)

This is B news patchlevel 19.

fascist() in funcs.c calls feof() before processing each line of the
authorized file, so the last line of authorized is always ignored.  Moving
the feof() call to the last statement in the while loop fixes it, but
I'm not sure why feof() is needed to begin with.  There is already a
check for EOF in the statement which fscanf()s the authorized file.
Am I missing something.

Simple patch follows.

*** ofuncs.c	Mon Apr  9 15:22:21 1990
--- funcs.c	Mon Apr  9 15:26:40 1990
***************
*** 684,691 ****
  	facfd = fopen(factemp, "r");
  	if (facfd != NULL) { /* If no such file, use global default only */
  		while (fscanf(facfd, "%[^:]:%s\n", facuser, factemp) != EOF) {
- 			if (feof(facfd))
- 				break;
  			if (facuser[0] == '#') continue;
  			if (facuser[0] == '\\') {
  				if (!grplist) grplist = getgrplist(user);
--- 684,689 ----
***************
*** 701,706 ****
--- 699,706 ----
  				(void) strcat(facgroups, factemp);
  				break;
  			}
+ 			if (feof(facfd))
+ 				break;
  		}
  		fclose (facfd);
  	}

--
Roger A. Cornelius          rac@sherpa.UUCP         uunet!sherpa!rac