[comp.bugs.4bsd] Bug in vi on NFS systems + FIX

db@its63b.UUCP (08/31/87)

Subject: 	vi can crash when used on remote file systems

Description: 	vi sets the maximum size of some buffers to be the block size
		of the machine it's compiled on (by including <sys/param.h>).
		If you use NFS, there is no guarantee that all files will be
		created using this block size.

Repeat by:	Install NFS on two machines.  Give them different block sizes.
		Invoke vi on the machine with the smaller block size (machine
		A), on a file on the other machine (machine B).  If the file is
		larger than the block size on machine A, vi will dump core.
		This happened on our Suns, which have 8k blocks, editing files
		on our Pyramid, which has 16k blocks.

Fix:		Include the following macro in "ex.h":

		#define min (a,b)	(a > b ? b : a)

		Then find all assignments involving "foo.st_blksize" on the
		rhs (where "foo" is either "statb" or "sbuf"), and replace the
		rhs by

		min (foo.st_blksize, MAXBSIZE);

		There are five such assignments, in the following files:

		ex_cmdsub.c
		ex_io.c		(2 occurrences)
		ex_tagio.c
		ex_unix.c