From: Carlos O'Donell <carlos@redhat.com>
To: Andreas Schwab <schwab@suse.de>, libc-alpha@sourceware.org
Subject: Re: [PATCH] mtrace: make shell commands robust against meta characters
Date: Thu, 20 Jun 2024 14:03:20 -0400 [thread overview]
Message-ID: <48aaefaa-f977-4691-8732-eb77ab983b1a@redhat.com> (raw)
In-Reply-To: <mvmjzijn5wf.fsf@suse.de>
On 6/20/24 8:41 AM, Andreas Schwab wrote:
> Use the list form of the open function to avoid interpreting meta
> characters in the arguments.
Agreed. LGTM.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> ---
> malloc/mtrace.pl | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/malloc/mtrace.pl b/malloc/mtrace.pl
> index ba14be6cae..1d5c723637 100644
> --- a/malloc/mtrace.pl
> +++ b/malloc/mtrace.pl
> @@ -86,7 +86,7 @@ if ($#ARGV == 0) {
> }
> # Set the environment variable LD_TRACE_LOADED_OBJECTS to 2 so the
> # executable is also printed.
> - if (open (locs, "env LD_TRACE_LOADED_OBJECTS=2 $prog |")) {
> + if (open (locs, "-|", "env", "LD_TRACE_LOADED_OBJECTS=2", $prog)) {
OK, locs specified and "-|" specifies command which pipes output to caller.
> while (<locs>) {
> chop;
> if (/^.*=> (.*) .(0x[0123456789abcdef]*).$/) {
> @@ -103,7 +103,7 @@ if ($#ARGV == 0) {
> sub addr2line {
> my $addr = pop(@_);
> my $prog = pop(@_);
> - if (open (ADDR, "addr2line -e $prog $addr|")) {
> + if (open (ADDR, "-|", "addr2line", "-e", $prog, $addr)) {
OK. Likewise.
> my $line = <ADDR>;
> chomp $line;
> close (ADDR);
--
Cheers,
Carlos.
prev parent reply other threads:[~2024-06-20 18:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-20 12:41 Andreas Schwab
2024-06-20 18:03 ` Carlos O'Donell [this message]
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=48aaefaa-f977-4691-8732-eb77ab983b1a@redhat.com \
--to=carlos@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=schwab@suse.de \
/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).