aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2024-09-24 13:23:10 +0200
committerFlorian Weimer <fweimer@redhat.com>2024-09-24 13:23:10 +0200
commit9802c0f2fec787ffcd192e1f2d6871dc586c6dad (patch)
treea2e313b59c98631f436394b7e2efa3a429bdddf7
parentbdaf50035354407add60d080d68fabe127330563 (diff)
downloadglibc-9802c0f2fec787ffcd192e1f2d6871dc586c6dad.zip
glibc-9802c0f2fec787ffcd192e1f2d6871dc586c6dad.tar.gz
glibc-9802c0f2fec787ffcd192e1f2d6871dc586c6dad.tar.bz2
elf: Eliminate alloca in open_verify
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.
-rw-r--r--elf/dl-load.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index c47ae09..ac8e217 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -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. */