Better with the patch file... Sorry. The Resend did not add the joint file I added with first message (in HTML format, refused). Hope it's OK now. Tony
Index: libbacktrace/ChangeLog =================================================================== --- libbacktrace/ChangeLog (revision 250609) +++ libbacktrace/ChangeLog (working copy) @@ -1,3 +1,7 @@ +2017-07-27 Tony Reix <tony.r...@atos.net> + + * xcoff.c: Don't leak a file descriptor if an archive is malformed. + 2017-07-26 Tony Reix <tony.r...@atos.net> * configure.ac: Check for XCOFF32/XCOFF64. Check for loadquery. Index: libbacktrace/xcoff.c =================================================================== --- libbacktrace/xcoff.c (revision 250609) +++ libbacktrace/xcoff.c (working copy) @@ -1288,7 +1288,7 @@ xcoff_armem_add (struct backtrace_state *state, in 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)); @@ -1295,13 +1295,13 @@ xcoff_armem_add (struct backtrace_state *state, in 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, in 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, in backtrace_release_view (state, &view, error_callback, data); } + fail: /* No matching member found. */ backtrace_close (descriptor, error_callback, data); return 0;