bfd/
[deliverable/binutils-gdb.git] / bfd / bfdio.c
index 51555bdd0db1be55c635ed2dbfc0188496a36735..0df25c3baf804feec966c090f413ef32702f8e9c 100644 (file)
@@ -1,7 +1,7 @@
 /* Low-level I/O routines for BFDs.
 
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
 
    Written by Cygnus Support.
@@ -20,15 +20,13 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #include "sysdep.h"
-
+#include <limits.h>
 #include "bfd.h"
 #include "libbfd.h"
 
-#include <limits.h>
-
 #ifndef S_IXUSR
 #define S_IXUSR 0100    /* Execute by owner.  */
 #endif
@@ -63,6 +61,16 @@ real_fseek (FILE *file, file_ptr offset, int whence)
 #endif
 }
 
+FILE *
+real_fopen (const char *filename, const char *modes)
+{
+#if defined (HAVE_FOPEN64)
+  return fopen64 (filename, modes);
+#else
+  return fopen (filename, modes);
+#endif
+}
+
 /*
 INTERNAL_DEFINITION
        struct bfd_iovec
@@ -106,6 +114,15 @@ bfd_bread (void *ptr, bfd_size_type size, bfd *abfd)
 {
   size_t nread;
 
+  /* If this is an archive element, don't read past the end of
+     this element.  */
+  if (abfd->arelt_data != NULL)
+    {
+      size_t maxbytes = ((struct areltdata *) abfd->arelt_data)->parsed_size;
+      if (size > maxbytes)
+       size = maxbytes;
+    }
+
   if ((abfd->flags & BFD_IN_MEMORY) != 0)
     {
       struct bfd_in_memory *bim;
@@ -391,7 +408,7 @@ FUNCTION
        bfd_get_size
 
 SYNOPSIS
-       long bfd_get_size (bfd *abfd);
+       file_ptr bfd_get_size (bfd *abfd);
 
 DESCRIPTION
        Return the file size (as read from file system) for the file
@@ -419,7 +436,7 @@ DESCRIPTION
        size reasonable?".
 */
 
-long
+file_ptr
 bfd_get_size (bfd *abfd)
 {
   struct stat buf;
This page took 0.02557 seconds and 4 git commands to generate.