Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!uunet!mcsun!unido!infko!droege From: droege@infko.UUCP (Detlev Droege G 207) Newsgroups: comp.os.minix Subject: BUG in 1.5.10 commands/file.c (and fix) Message-ID: <1280@infko.UUCP> Date: 9 Aug 90 14:29:05 GMT Reply-To: droege@infko.UUCP (Detlev Droege G 207) Organization: University of Koblenz (EWH), West Germany Lines: 34 Hi folks, there is a small but nasty bug in commands/file.c which causes it to dump core on empty files. The case of zero length files is not tested for and thus drives the type-guessing for-loop mad ... The fix is easy, see patch below. And it makes it conformant to the behaviour of the file commands I'm used to on BSD and SysV. Bye Detlev ---------------- cut here for best results ---------------- *** file.c.orig Thu Aug 9 15:15:42 1990 --- file.c Thu Aug 9 15:15:35 1990 *************** *** 81,86 **** --- 81,91 ---- close(fd); return; } + if (n == 0) { /* must check this, for loop will fail otherwise !! */ + printf("empty file\n"); + close(fd); + return; + } /* Check to see if file is an archive. */ #if (CHIP == M68000) ----------------------------------------------------------- -- Detlev Droege, Uni Koblenz (EWH), FB Informatik Rheinau 3-4, D-5400 Koblenz (Germany) UUCP: ..!unido!infko!droege droege@infko.UUCP (Voice: +49 261 9119-421)