about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2024-06-20 14:13:01 +0200
committerAndreas Schwab <schwab@suse.de>2024-06-24 09:33:49 +0200
commit2a6c922f09e7a1c206e0cbdb4424f1cf101a5bda (patch)
treeda15f9d6c5b676037cad50ecb701b33b451f8277
parentaecde502e9bb20a30b0f111b5a690af1746b78ef (diff)
downloadglibc-2a6c922f09e7a1c206e0cbdb4424f1cf101a5bda.tar.gz
glibc-2a6c922f09e7a1c206e0cbdb4424f1cf101a5bda.tar.xz
glibc-2a6c922f09e7a1c206e0cbdb4424f1cf101a5bda.zip
mtrace: make shell commands robust against meta characters
Use the list form of the open function to avoid interpreting meta
characters in the arguments.
-rw-r--r--malloc/mtrace.pl4
1 files changed, 2 insertions, 2 deletions
diff --git a/malloc/mtrace.pl b/malloc/mtrace.pl
index 0a631a07bc..32b4da935f 100644
--- a/malloc/mtrace.pl
+++ b/malloc/mtrace.pl
@@ -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);