Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!sri-spam!ames!lll-lcc!lll-tis!ptsfa!hoptoad!academ!uhnix1!sugar!peter From: peter@sugar.UUCP (Peter da Silva) Newsgroups: comp.sys.amiga,comp.sources.bugs Subject: Bug in uupc Message-ID: <563@sugar.UUCP> Date: Tue, 25-Aug-87 06:26:51 EDT Article-I.D.: sugar.563 Posted: Tue Aug 25 06:26:51 1987 Date-Received: Sat, 29-Aug-87 08:56:55 EDT Organization: Sugar Land UNIX - Houston, TX Lines: 35 Keywords: uupc amiga genv.c getone() Xref: mnetor comp.sys.amiga:7842 comp.sources.bugs:227 The following function, which seems to be an overly complex version of fgetc(fp), has a serious bug in it. It's from "genv.c" in the Amiga code for the uupc program. Basically, line[256] has to be static. I find it hard to believe that this code was ever tested... because there is no way line[] will remain valid from invocation to invocation. In addition, the function is entirely superfluous since it's identical in function to "fgetc()". /*--------------------------------------------------------------*/ /* getone: get next character file f. f already open */ /*--------------------------------------------------------------*/ static int getone( f ) FILE *f; { char c, line[256]; static int pos = 0; static int len = 0; if ( ++pos > len || line[pos] == '\0' ) { if ( fgets( line, 255, f ) == NULL ) return EOF; pos = 0; len = strlen( line ); } c = line[pos]; return c; } -- -- Peter da Silva `-_-' ...!seismo!soma!uhnix1!sugar!peter -- U <--- not a copyrighted cartoon :->