[net.unix-wizards] Minor bug in msgs.c

bzs@BU-CS.BU.EDU (Barry Shein) (08/06/86)

[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