[net.bugs.usg] Bug in System V GPS pd.c and ptog.c

dan@rna.UUCP (Dan Ts'o) (01/14/85)

Hi,
	There is a common bug in the System V GPS graphics package, in
the two programs that deal with the plot(5) format. Basically, when the
programs were converted to the 32bit VAX from the 16bit PDP-11 on which
plot(5) grew up, though the program was adjusted for the word size,
the spec that plot(5) requires signed (int)'s was forgotten.
	Both pd.c (human readable dump of plot(5)) and ptog.c (plot(5)
to GPS filter) contain a routine get2b() to fetch the next two bytes
(a (short)) of plot(5) data. The declaration needs to be changed to
"short" from "int" to get a 16-bit 2byte integer datum. The two changes
are comment /* dyt */ below...

					Cheers,
					Dan Ts'o
					Dept. Neurobiology
					Rockefeller Univ.
					1230 York Ave.
					NY, NY 10021
					212-570-7671
					...cmcl2!rna!dan

get2b(fptr)		/* get an integer stored in 2 ascii bytes. */
FILE *fptr;
{
	short a, b;			/* dyt - was int */
	if((b = getc(fptr)) == EOF) {
		ERRPR0(Format error);
		return(EOF);
	}
	if((a = getc(fptr)) == EOF) {
		ERRPR0(Format error);
		return(EOF);
	}
	a <<= 8;
	return((int)a|b);		/* dyt */
}