aboutsummaryrefslogtreecommitdiff
path: root/libbacktrace
diff options
context:
space:
mode:
authorTony Reix <tony.reix@atos.net>2017-07-28 18:52:13 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-07-28 18:52:13 +0000
commitafce7debdc589469bd025d5c65697598c6ef325f (patch)
tree18d647a6aca3006653df48d0d43c1e7bbadd21a7 /libbacktrace
parent9761988fc78d16fe36fbb7f000c6b55e7fa83787 (diff)
downloadgcc-afce7debdc589469bd025d5c65697598c6ef325f.zip
gcc-afce7debdc589469bd025d5c65697598c6ef325f.tar.gz
gcc-afce7debdc589469bd025d5c65697598c6ef325f.tar.bz2
* xcoff.c: Don't leak a file descriptor if an archive is malformed.
From-SVN: r250684
Diffstat (limited to 'libbacktrace')
-rw-r--r--libbacktrace/ChangeLog4
-rw-r--r--libbacktrace/xcoff.c9
2 files changed, 9 insertions, 4 deletions
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog
index c60f714..313a4c6 100644
--- a/libbacktrace/ChangeLog
+++ b/libbacktrace/ChangeLog
@@ -1,3 +1,7 @@
+2017-07-28 Tony Reix <tony.reix@atos.net>
+
+ * xcoff.c: Don't leak a file descriptor if an archive is malformed.
+
2017-07-28 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* fileline.c (fileline_initialize): Print pid_t as long.
diff --git a/libbacktrace/xcoff.c b/libbacktrace/xcoff.c
index 7621073..2faa9fd 100644
--- a/libbacktrace/xcoff.c
+++ b/libbacktrace/xcoff.c
@@ -1288,20 +1288,20 @@ xcoff_armem_add (struct backtrace_state *state, int descriptor,
if (!backtrace_get_view (state, descriptor, 0, sizeof (b_ar_fl_hdr),
error_callback, data, &view))
- return 0;
+ goto fail;
memcpy (&fl_hdr, view.data, sizeof (b_ar_fl_hdr));
backtrace_release_view (state, &view, error_callback, data);
if (memcmp (fl_hdr.fl_magic, AIAMAGBIG, 8) != 0)
- return 0;
+ goto fail;
memlen = strlen (member);
/* Read offset of first archive member. */
if (!xcoff_parse_decimal (fl_hdr.fl_fstmoff, sizeof fl_hdr.fl_fstmoff, &off))
- return 0;
+ goto fail;
while (off != 0)
{
/* Map archive member header and member name. */
@@ -1309,7 +1309,7 @@ xcoff_armem_add (struct backtrace_state *state, int descriptor,
if (!backtrace_get_view (state, descriptor, off,
sizeof (b_ar_hdr) + memlen,
error_callback, data, &view))
- return 0;
+ break;
ar_hdr = (const b_ar_hdr *) view.data;
@@ -1345,6 +1345,7 @@ xcoff_armem_add (struct backtrace_state *state, int descriptor,
backtrace_release_view (state, &view, error_callback, data);
}
+ fail:
/* No matching member found. */
backtrace_close (descriptor, error_callback, data);
return 0;