mtrace: make shell commands robust against meta characters
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
redhat-pt-bot/TryBot-32bit |
success
|
Build for i686
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Test passed
|
Commit Message
Use the list form of the open function to avoid interpreting meta
characters in the arguments.
---
malloc/mtrace.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
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);
@@ -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)) {
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)) {
my $line = <ADDR>;
chomp $line;
close (ADDR);