4.2 BSD nm bug
jm at wlbr.UUCP
jm at wlbr.UUCP
Tue Jun 12 14:06:05 AEST 1984
Subject: nm fails to close files when errors occur
Index: src/nm.c 4.2BSD
Description:
When nm is given a file without a reasonable magic number,
it fails to close it before proceeding on to the next one.
Repeat-By:
Run the following command in a directory with some executables,
and some data files:
nm -o * | fgrep <symbol name>
After so many bad files, nm will produce an error for every
remaining file in its argument list.
Fix:
The following changes will make nm close the file before proceeding
on to the next one. (Whew... all this garbage for only changing
two lines!!!)
*** nm.c.old Tue Jun 5 17:32:56 1984
--- nm.c Tue Jun 5 17:34:41 1984
***************
*** 99,105
fread((char *)&mag_un, 1, sizeof(mag_un), fi);
if (mag_un.mag_exp.a_magic == OARMAG) {
error(0, "old archive");
! return;
}
if (strncmp(mag_un.mag_armag, ARMAG, SARMAG)==0)
archive++;
--- 99,105 -----
fread((char *)&mag_un, 1, sizeof(mag_un), fi);
if (mag_un.mag_exp.a_magic == OARMAG) {
error(0, "old archive");
! goto out;
}
if (strncmp(mag_un.mag_armag, ARMAG, SARMAG)==0)
archive++;
***************
*** 105,111
archive++;
else if (N_BADMAG(mag_un.mag_exp)) {
error(0, "bad format");
! return;
}
fseek(fi, 0L, 0);
if (archive) {
--- 105,111 -----
archive++;
else if (N_BADMAG(mag_un.mag_exp)) {
error(0, "bad format");
! goto out;
}
fseek(fi, 0L, 0);
if (archive) {
More information about the Comp.unix.wizards
mailing list