Minor bug in msgs.c

Barry Shein bzs at BU-CS.BU.EDU
Thu Aug 7 05:08:48 AEST 1986


[4.3bsd]

DESCRIPTION:

If msgs finds an out of bounds .msgsrc it warns the user
and truncates it in preparation to reset it to a more
sane value. Unfortunately, it calls ftruncate() on a file
(.msgsrc) it just fclose'd.

REPEAT-BY:

Set your .msgsrc to some ridiculously high value, run msgs,
get warning message, quit. Look at .msgsrc file, it will
have two lines in it rather than one.

FIX:

Change (the only)
	ftruncate(fileno(msgsrc),0);
to
	truncate(fname,0);

(the code then goes on to re-open the file shortly thereafter so
it can update it.)

	-Barry Shein, Boston University



More information about the Comp.unix.wizards mailing list