diff mbox series

[v3,08/32] elf: Eliminate alloca in open_verify

Message ID 68d85e17f654a9524cbb02838cd74bddb0826388.1701944612.git.fweimer@redhat.com
State New
Headers show
Series RELRO linkmaps | expand

Commit Message

Florian Weimer Dec. 7, 2023, 10:31 a.m. UTC
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 | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Joseph Myers Feb. 19, 2024, 11:26 p.m. UTC | #1
On Thu, 7 Dec 2023, Florian Weimer wrote:

> 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.

OK.
diff mbox series

Patch

diff --git a/elf/dl-load.c b/elf/dl-load.c
index 2084366663..d355de036a 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1636,15 +1636,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.  */