From: Florian Weimer <fweimer@redhat.com>
To: Sergey Bugaev <bugaevc@gmail.com>
Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org,
Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Subject: Re: [RFC PATCH 1/2] elf: Port ldconfig away from stack-allocated paths
Date: Thu, 25 May 2023 10:07:55 +0200 [thread overview]
Message-ID: <87ttw0omuc.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20230520190306.4008296-1-bugaevc@gmail.com> (Sergey Bugaev's message of "Sat, 20 May 2023 22:03:06 +0300")
* Sergey Bugaev:
> diff --git a/elf/ldconfig.c b/elf/ldconfig.c
> index 2fc45ad8..e643dd57 100644
> --- a/elf/ldconfig.c
> +++ b/elf/ldconfig.c
> - len = strlen (dir_name) + strlen (direntry->d_name) + 2;
> - if (len > real_file_name_len)
> - {
> - real_file_name_len = len;
> - real_file_name = alloca (real_file_name_len);
> - }
> - sprintf (real_file_name, "%s/%s", dir_name, direntry->d_name);
> + if (asprintf (&real_file_name, "%s/%s",
> + dir_name, direntry->d_name) < 0)
> + error (EXIT_FAILURE, errno, _("Could not form library path"));
> }
> + else
> + real_file_name = file_name;
Maybe use xstrdup (file_name) here and free unconditionally below?
It makes it easier to analyze the code for use-after-free errors.
Rest looks okay.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Thanks,
Florian
next prev parent reply other threads:[~2023-05-25 8:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-17 18:54 [RFC PATCH 0/2] On ldconfig and ld.so.cache Sergey Bugaev
2023-05-17 18:54 ` [RFC PATCH 1/2] elf: Port ldconfig away from stack-allocated paths Sergey Bugaev
2023-05-18 19:13 ` Adhemerval Zanella Netto
2023-05-19 12:25 ` Florian Weimer
2023-05-20 19:03 ` Sergey Bugaev
2023-05-23 17:57 ` Adhemerval Zanella Netto
2023-05-25 8:07 ` Florian Weimer [this message]
2023-05-17 18:54 ` [RFC PATCH 2/2] x86: Make dl-cache.h and readelflib.c not Linux-specific Sergey Bugaev
2023-05-19 11:36 ` Carlos O'Donell
2023-05-19 11:52 ` [RFC PATCH 0/2] On ldconfig and ld.so.cache Carlos O'Donell
2023-05-19 12:30 ` Florian Weimer
2023-05-19 13:21 ` Sergey Bugaev
2023-05-24 14:09 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ttw0omuc.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=adhemerval.zanella@linaro.org \
--cc=bug-hurd@gnu.org \
--cc=bugaevc@gmail.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).