summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-06-22 15:56:45 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-06-22 15:56:45 +0000
commit0e488909c71aa4d1cc21ed7dbfb5b99551c99af1 (patch)
tree3d6a1c57134dc91036ab75f3b90d83506a5be8ec /utils
parent93d47a36f80f3fc6495f8b7e57fd85c0089c60d3 (diff)
downloadperl-0e488909c71aa4d1cc21ed7dbfb5b99551c99af1.tar.gz
Debian fix from Brendan O'Dea:
Use a temporary directory to avoid symlink attacks. Specify -gstabs explicitly (not the default format for gcc 3.2). p4raw-id: //depot/perl@19837
Diffstat (limited to 'utils')
-rw-r--r--utils/c2ph.PL26
1 files changed, 20 insertions, 6 deletions
diff --git a/utils/c2ph.PL b/utils/c2ph.PL
index 655ae294c1..91ecc04552 100644
--- a/utils/c2ph.PL
+++ b/utils/c2ph.PL
@@ -353,13 +353,25 @@ delete $intrinsics{'null'};
$indent = 2;
$CC = 'cc';
-$CFLAGS = '-g -S';
+!NO!SUBS!
+
+if (($Config{gccversion} || '') =~ /^(\d+)\.(\d+)/
+ and ($1 > 3 or ($1 == 3 and $2 >= 2))) {
+ print OUT q/$CFLAGS = '-gstabs -S';/;
+} else {
+ print OUT q/$CFLAGS = '-g -S';/;
+}
+
+print OUT <<'!NO!SUBS!';
+
$DEFINES = '';
$perl++ if $0 =~ m#/?c2ph$#;
require 'getopts.pl';
+use File::Temp 'tempdir';
+
eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;
&Getopts('aixdpvtnws:') || &usage(0);
@@ -488,9 +500,10 @@ if (@ARGV) {
$ARGV[0] =~ s/\.c$/.s/;
}
else {
- $TMP = "/tmp/c2ph.$$.c";
+ $TMPDIR = tempdir(CLEANUP => 1);
+ $TMP = "$TMPDIR/c2ph.$$.c";
&system("cat @ARGV > $TMP") && exit 1;
- &system("cd /tmp; $CC $CFLAGS $DEFINES $TMP") && exit 1;
+ &system("cd $TMPDIR; $CC $CFLAGS $DEFINES $TMP") && exit 1;
unlink $TMP;
$TMP =~ s/\.c$/.s/;
@ARGV = ($TMP);
@@ -1261,7 +1274,8 @@ sub fetch_template {
}
sub compute_intrinsics {
- local($TMP) = "/tmp/c2ph-i.$$.c";
+ $TMPDIR ||= tempdir(CLEANUP => 1);
+ local($TMP) = "$TMPDIR/c2ph-i.$$.c";
open (TMP, ">$TMP") || die "can't open $TMP: $!";
select(TMP);
@@ -1289,7 +1303,7 @@ EOF
close TMP;
select(STDOUT);
- open(PIPE, "cd /tmp && $CC $TMP && /tmp/a.out|");
+ open(PIPE, "cd $TMPDIR && $CC $TMP && $TMPDIR/a.out|");
while (<PIPE>) {
chop;
split(' ',$_,2);;
@@ -1298,7 +1312,7 @@ EOF
$intrinsics{$_[1]} = $template{$_[0]};
}
close(PIPE) || die "couldn't read intrinsics!";
- unlink($TMP, '/tmp/a.out');
+ unlink($TMP, '$TMPDIR/a.out');
print STDERR "done\n" if $trace;
}