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.
This commit is contained in:
Florian Weimer 2024-09-24 13:23:10 +02:00
parent bdaf500353
commit 9802c0f2fe

View File

@ -1592,15 +1592,13 @@ open_verify (const char *name, int fd,
errval = errno; errval = errno;
errstring = (errval == 0 errstring = (errval == 0
? N_("file too short") : N_("cannot read file data")); ? N_("file too short") : N_("cannot read file data"));
lose: lose:;
struct dl_exception exception;
_dl_exception_create (&exception, name, errstring);
if (free_name) if (free_name)
{ free ((char *) name);
char *realname = (char *) name;
name = strdupa (realname);
free (realname);
}
__close_nocancel (fd); __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. */ /* See whether the ELF header is what we expect. */