Summary: | Potential UB in bfd_set_error | ||
---|---|---|---|
Product: | binutils | Reporter: | Pavel I. Kryukov <kryukov> |
Component: | binutils | Assignee: | Alan Modra <amodra> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 2.29 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: | 2017-10-04 00:00:00 | |
Attachments: | Fix potential UB in bfd_set_error |
Description
Pavel I. Kryukov
2017-10-03 20:04:22 UTC
Created attachment 10503 [details]
Fix potential UB in bfd_set_error
Thanks for the patch. Will apply. The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9ba5f27cdd15d22d6c5739ff5d2b1c81d796e114 commit 9ba5f27cdd15d22d6c5739ff5d2b1c81d796e114 Author: Pavel I. Kryukov <kryukov@frtk.ru> Date: Tue Oct 3 22:42:07 2017 +0300 PR22245, Fix potential UB in bfd_set_error Passing enum as a first argument to variadic argument function may lead to undefined behavior. The explanation on CERT site: https://www.securecoding.cert.org/confluence/display/cplusplus/ EXP58-CPP.+Pass+an+object+of+the+correct+type+to+va_start The bug was found by Kirill Nedostoev (nedostoev.ka@phystech.edu) when he tried to build GNU binutils with Clang 7. PR 22245 * bfd.c (bfd_set_error): Avoid UB on passing arg to va_start that undergoes default promotion. * bfd-in2.h: Regenerate. The binutils-2_29-branch branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=99ca76d3db25af8e017d7d54df677db0561907f5 commit 99ca76d3db25af8e017d7d54df677db0561907f5 Author: Pavel I. Kryukov <kryukov@frtk.ru> Date: Tue Oct 3 22:42:07 2017 +0300 PR22245, Fix potential UB in bfd_set_error Passing enum as a first argument to variadic argument function may lead to undefined behavior. The explanation on CERT site: https://www.securecoding.cert.org/confluence/display/cplusplus/ EXP58-CPP.+Pass+an+object+of+the+correct+type+to+va_start The bug was found by Kirill Nedostoev (nedostoev.ka@phystech.edu) when he tried to build GNU binutils with Clang 7. PR 22245 * bfd.c (bfd_set_error): Avoid UB on passing arg to va_start that undergoes default promotion. * bfd-in2.h: Regenerate. (cherry picked from commit 9ba5f27cdd15d22d6c5739ff5d2b1c81d796e114) Thank you! The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2ca7de3746be7484aa5affceafa1ad2e1d789381 commit 2ca7de3746be7484aa5affceafa1ad2e1d789381 Author: Pedro Alves <palves@redhat.com> Date: Wed Oct 4 14:20:51 2017 +0100 bfd_set_input_error A downside to the 2017-10-04 PR22245 fix is that bfd_set_error can now silently accept invalid errors if/when someone passes the a value of the wrong enumeration type, which previously would be caught by the -Wenum-conversion warning. PR 22245 * bfd.c (bfd_set_error): Revert 2017-10-04 change. Remove ellipsis parameter. Split out bfd_error_on_input code to.. (bfd_set_input_error): .. New function. * archive.c (_bfd_write_archive_contents): Use bfd_set_input_error. * vms-lib.c (_bfd_vms_lib_write_archive_contents): Likewise. * bfd-in2.h: Regenerate. |