clearlogs
logmsg
runclient
+ shell_quote
subbase64
subnewlines
);
}
if(!$tool) {
- $CMDLINE="$CURL";
+ $CMDLINE=shell_quote($CURL);
}
if(use_valgrind() && !$disablevalgrind) {
if ($torture) {
$cmdres = torture($CMDLINE,
$testnum,
- "$gdb --directory $LIBDIR $DBGCURL -x $LOGDIR/gdbcmd");
+ "$gdb --directory $LIBDIR " . shell_quote($DBGCURL) . " -x $LOGDIR/gdbcmd");
}
elsif($gdbthis) {
my $GDBW = ($gdbxwin) ? "-w" : "";
- runclient("$gdb --directory $LIBDIR $DBGCURL $GDBW -x $LOGDIR/gdbcmd");
+ runclient("$gdb --directory $LIBDIR " . shell_quote($DBGCURL) . " $GDBW -x $LOGDIR/gdbcmd");
$cmdres=0; # makes it always continue after a debugged run
}
else {
open(my $gdbcmd, ">", "$LOGDIR/gdbcmd2") || die "Failure writing gdb file";
print $gdbcmd "bt\n";
close($gdbcmd) || die "Failure writing gdb file";
- runclient("$gdb --directory libtest -x $LOGDIR/gdbcmd2 -batch $DBGCURL core ");
+ runclient("$gdb --directory libtest -x $LOGDIR/gdbcmd2 -batch " . shell_quote($DBGCURL) . " core ");
# unlink("$LOGDIR/gdbcmd2");
}
}
my $curlverout="$LOGDIR/curlverout.log";
my $curlvererr="$LOGDIR/curlvererr.log";
- my $versioncmd="$CURL --version 1>$curlverout 2>$curlvererr";
+ my $versioncmd=shell_quote($CURL) . " --version 1>$curlverout 2>$curlvererr";
unlink($curlverout);
unlink($curlvererr);
$http_unix = 1 if($sws[0] =~ /unix/);
}
- open(my $manh, "-|", "$CURL -M 2>&1");
+ open(my $manh, "-|", shell_quote($CURL) . " -M 2>&1");
while(my $s = <$manh>) {
if($s =~ /built-in manual was disabled at build-time/) {
$feature{"manual"} = 0;
}
elsif ($ARGV[0] eq "-c") {
# use this path to curl instead of default
- $DBGCURL=$CURL="\"$ARGV[1]\"";
+ $DBGCURL=$CURL=$ARGV[1];
shift @ARGV;
}
elsif ($ARGV[0] eq "-vc") {
# the development version as then it won't be able to run any tests
# since it can't verify the servers!
- $VCURL="\"$ARGV[1]\"";
+ $VCURL=shell_quote($ARGV[1]);
shift @ARGV;
}
elsif ($ARGV[0] eq "-ac") {
# use this curl only to talk to APIs (currently only CI test APIs)
- $ACURL="\"$ARGV[1]\"";
+ $ACURL=shell_quote($ARGV[1]);
shift @ARGV;
}
elsif ($ARGV[0] eq "-d") {
localtime(time);
# seed of the month. December 2019 becomes 201912
$randseed = ($year+1900)*100 + $mon+1;
- open(my $curlvh, "-|", "$CURL --version 2>/dev/null") ||
+ open(my $curlvh, "-|", shell_quote($CURL) . " --version 2>/dev/null") ||
die "could not get curl version!";
my @c = <$curlvh>;
close($curlvh) || die "could not get curl version!";
runclient
runclientoutput
setlogfunc
+ shell_quote
subbase64
subnewlines
);
# return @out;
}
+
+#######################################################################
+# Quote an argument for passing safely to a Bourne shell
+# This does the same thing as String::ShellQuote but doesn't need a package.
+#
+sub shell_quote {
+ my ($s)=@_;
+ if($s !~ m/^[-+=.,_\/:a-zA-Z0-9]+$/) {
+ # string contains a "dangerous" character--quote it
+ $s =~ s/'/'"'"'/g;
+ $s = "'" . $s . "'";
+ }
+ return $s;
+}
+
1;