]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
mtrace: make shell commands robust against meta characters
authorAndreas Schwab <schwab@suse.de>
Thu, 20 Jun 2024 12:13:01 +0000 (14:13 +0200)
committerAndreas Schwab <schwab@suse.de>
Mon, 24 Jun 2024 07:33:49 +0000 (09:33 +0200)
Use the list form of the open function to avoid interpreting meta
characters in the arguments.

malloc/mtrace.pl

index 0a631a07bc4cfbb62e5212d6ea88d36bcada9193..32b4da935f7c7c4ae4f1f260b7850abed7a1ea87 100644 (file)
@@ -87,7 +87,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)) {
        while (<locs>) {
            chop;
            if (/^.*=> (.*) .(0x[0123456789abcdef]*).$/) {
@@ -104,7 +104,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)) {
        my $line = <ADDR>;
        chomp $line;
        close (ADDR);