aboutsummaryrefslogtreecommitdiff
path: root/bfd/archive.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2006-10-30 07:41:17 +0000
committerAlan Modra <amodra@gmail.com>2006-10-30 07:41:17 +0000
commitffda70fc2e3b04016ff2373c888aaaeafc09a46c (patch)
treed9f72f18af0b63476d413bb414767cd98bd4b5a2 /bfd/archive.c
parent406601a1e304bd2ddf2be6a1e2be7899df620a69 (diff)
downloadgdb-ffda70fc2e3b04016ff2373c888aaaeafc09a46c.zip
gdb-ffda70fc2e3b04016ff2373c888aaaeafc09a46c.tar.gz
gdb-ffda70fc2e3b04016ff2373c888aaaeafc09a46c.tar.bz2
* bfd.c (bfd_error_type): Add bfd_error_on_input.
(input_bfd, input_error): New static vars. (bfd_set_error): Handle bfd_error_on_input. (bfd_errmsg): Likewise. (bfd_perror): Simplify. * archive.c (_bfd_write_archive_contents): Report errors on input.
Diffstat (limited to 'bfd/archive.c')
-rw-r--r--bfd/archive.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/bfd/archive.c b/bfd/archive.c
index 947506d..22261ac 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -1,6 +1,6 @@
/* BFD back-end for archive files (libraries).
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004, 2005
+ 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault.
@@ -1647,14 +1647,14 @@ _bfd_write_archive_contents (bfd *arch)
if (bfd_write_p (current))
{
bfd_set_error (bfd_error_invalid_operation);
- return FALSE;
+ goto input_err;
}
if (!current->arelt_data)
{
current->arelt_data =
bfd_ar_hdr_from_filesystem (arch, current->filename, current);
if (!current->arelt_data)
- return FALSE;
+ goto input_err;
/* Put in the file name. */
BFD_SEND (arch, _bfd_truncate_arname,
@@ -1716,7 +1716,7 @@ _bfd_write_archive_contents (bfd *arch)
!= sizeof (*hdr))
return FALSE;
if (bfd_seek (current, (file_ptr) 0, SEEK_SET) != 0)
- return FALSE;
+ goto input_err;
while (remaining)
{
unsigned int amt = DEFAULT_BUFFERSIZE;
@@ -1726,8 +1726,8 @@ _bfd_write_archive_contents (bfd *arch)
if (bfd_bread (buffer, amt, current) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_malformed_archive);
- return FALSE;
+ bfd_set_error (bfd_error_file_truncated);
+ goto input_err;
}
if (bfd_bwrite (buffer, amt, arch) != amt)
return FALSE;
@@ -1760,6 +1760,10 @@ _bfd_write_archive_contents (bfd *arch)
}
return TRUE;
+
+ input_err:
+ bfd_set_error (bfd_error_on_input, current, bfd_get_error ());
+ return FALSE;
}
/* Note that the namidx for the first symbol is 0. */