🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2040

ar fails to close file on error

#2040
From: Ian Darwin
Date: Mon, 05 Dec 1988 17:32
47 lines
1853 bytes
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;
      }
  
Technical Details
Message-ID: <88Dec5.123304est.2518@sq.sq.com>
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!sq.sq.com!ian

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!sq.sq.com!ian
From: ian@sq.sq.com (Ian Darwin)
Newsgroups: gnu.gcc.bug
Subject: ar fails to close file on error
Message-ID: <88Dec5.123304est.2518@sq.sq.com>
Date: 5 Dec 88 17:32:51 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 46