[5832] in Athena Bugs
decmips 7.1H: more has an unaligned data access
daemon@ATHENA.MIT.EDU (Ezra Peisach)
Fri Aug 24 11:23:23 1990
To: bugs@ATHENA.MIT.EDU
Date: Fri, 24 Aug 90 11:23:07 EDT
From: Ezra Peisach <epeisach@ATHENA.MIT.EDU>
System name: BOOM
Type and version: KN01 7.1H (1 update(s) to same version)
Display type: PM-MONO
What were you trying to do?
more a zero length file
What's wrong:
Fixed up unaligned data access for pid 17231 (more) at pc 0x400d8
This is probably the same bug that Ken R. reported if you more a zero
length file on the RT console.
What should have happened:
Should have had proper behavior
Please describe any relevant documentation references:
more(1)
Fix below:
Move the check for zero length file before code that tries reading the
first byte, failing and trying to read byte -1.
Ezra
*** /tmp/,RCSt1a17225 Fri Aug 24 11:18:14 1990
--- more.c Fri Aug 24 11:03:47 1990
***************
*** 403,408 ****
--- 403,414 ----
perror(fs);
return (NULL);
}
+
+ if ((file_size = stbuf.st_size) == 0) {
+ file_size = ULONG_MAX;
+ return(f);
+ }
+
c = Getc(f);
k = *(unsigned int *)((char *)f->_ptr - 1);
/* Try to see whether it is an ASCII file */
***************
*** 435,442 ****
*clearfirst = 0;
Ungetc (c, f);
}
- if ((file_size = stbuf.st_size) == 0)
- file_size = ULONG_MAX;
return (f);
}
--- 441,446 ----