[PATCH dlltool] Avoid segfaulting if output_def can't be opened for writing

Stephen Kitt steve@sk2.org
Thu May 28 19:09:00 GMT 2015


Hi,

As reported in https://bugs.debian.org/519788, dlltool segfaults if the
output-def file can't be opened for writing. The following patch checks
the result of the corresponding fopen. (It may fuzz by one line depending
on whether my previous patch is applied or not.)

Signed-off-by: Stephen Kitt <steve@sk2.org>



diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index e83052a..2a6295c 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -4151,6 +4152,11 @@ main (int ac, char **av)
          break;
        case 'z':
          output_def = fopen (optarg, FOPEN_WT);
+
+         if (!output_def)
+           /* xgettext:c-format */
+           fatal (_("Unable to open def-file: %s"), optarg);
+
          break;
        case 'D':
          dll_name = (char*) lbasename (optarg);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/binutils/attachments/20150528/f45c76da/attachment.sig>


More information about the Binutils mailing list