ian@sq.sq.com (Ian Darwin) (12/06/88)
If binutils/ar gets a "bad string table" error, it forgets to close the file that it has opened. Enough of these and you run out of file descriptors. Here is a patch that closes the file if it opened it. This patch only finds two places where this bug comes up. There may be other bugs of this type in ar! *** /tmp/,RCSt1a13215 Mon Dec 5 12:28:32 1988 --- ar.c Mon Dec 5 12:28:24 1988 *************** *** 1435,1440 if (sizeof string_size != read (indesc, &string_size, sizeof string_size)) { error_with_file ("bad string table in ", mapelt); return; } --- 1435,1442 ----- if (sizeof string_size != read (indesc, &string_size, sizeof string_size)) { error_with_file ("bad string table in ", mapelt); + if (mapelt->info.data_offset) /* i.e., we just opened it */ + close(indesc); /* giving up on this file */ return; } *************** *** 1451,1456 if (totalsize != read (indesc, symbols_and_strings, totalsize)) { error_with_file ("premature end of file in symbols/strings of "); return; } --- 1453,1460 ----- if (totalsize != read (indesc, symbols_and_strings, totalsize)) { error_with_file ("premature end of file in symbols/strings of "); + if (mapelt->info.data_offset) /* i.e., we just opened it */ + close(indesc); /* giving up on this file */ return; }