]> sourceware.org Git - glibc.git/commitdiff
elf: Eliminate alloca in open_verify
authorFlorian Weimer <fweimer@redhat.com>
Tue, 24 Sep 2024 11:23:10 +0000 (13:23 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 24 Sep 2024 11:23:10 +0000 (13:23 +0200)
With the two-stage approach for exception handling, the name can
be freed after it has been copied into the exception, but before
it is raised.

elf/dl-load.c

index c47ae093f3dae37562b654e4645bbd4bc61ca371..ac8e217a7f40080c0ea41aee256484f02e907d6f 100644 (file)
@@ -1592,15 +1592,13 @@ open_verify (const char *name, int fd,
          errval = errno;
          errstring = (errval == 0
                       ? N_("file too short") : N_("cannot read file data"));
-       lose:
+       lose:;
+         struct dl_exception exception;
+         _dl_exception_create (&exception, name, errstring);
          if (free_name)
-           {
-             char *realname = (char *) name;
-             name = strdupa (realname);
-             free (realname);
-           }
+           free ((char *) name);
          __close_nocancel (fd);
-         _dl_signal_error (errval, name, NULL, errstring);
+         _dl_signal_exception (errval, &exception, NULL);
        }
 
       /* See whether the ELF header is what we expect.  */
This page took 0.042167 seconds and 5 git commands to generate.