diff options
author | Ralf Wildenhues <Ralf.Wildenhues@gmx.de> | 2007-12-08 11:46:43 +0100 |
---|---|---|
committer | Ralf Wildenhues <Ralf.Wildenhues@gmx.de> | 2007-12-08 11:46:43 +0100 |
commit | 449317f7ee33553165f46de6d818a44ee2cd7def (patch) | |
tree | 726f0db355a6c46465513c4ce3f7ca3035aaaaa5 /bin/autoupdate.in | |
parent | 7fb34e3eec4e64db248dc62bba8bf0e4af963750 (diff) | |
download | autoconf-449317f7ee33553165f46de6d818a44ee2cd7def.tar.gz |
Proper file name escaping in Autoconf programs and Perl modules.
This includes escaping of characters special to the shell
as well as special to Perl, e.g., leading `<' or `>'.
For example, when $file starts with `>', `open ">$file"'
wrongly tries to append to a different file.
* bin/autoconf.as: Fix quoting for autom4te options.
* lib/Autom4te/General.pm (shell_quote): New function, taken
from coreutils, written by Jim Meyering.
(mktmpdir): Use it.
* bin/autom4te.in (files_to_options, handle_m4): Use shell_quote
and open_quote.
* bin/autoreconf.in (parse_args): Likewise.
* bin/autoscan.in (main): Likewise.
* bin/autoupdate.in (main): Likewise.
* bin/autoheader.in: Likewise, fixing old insufficient escaping.
* bin/ifnames.in: Likewise, XFile usage fixes.
* tests/tools.at (autom4te and whitespace in file names): Extend
test. Test twice, with special characters allowed on w32, and the
rest. Test leading and trailing whitespace, for `open_quote'.
(autotools and whitespace in file names): New, analogous test.
Reported by Paul Eggert and Benoit Sigoure, additional suggestions
by Russ Allbery and Eric Blake.
Diffstat (limited to 'bin/autoupdate.in')
-rw-r--r-- | bin/autoupdate.in | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/bin/autoupdate.in b/bin/autoupdate.in index d69211d6..23060f29 100644 --- a/bin/autoupdate.in +++ b/bin/autoupdate.in @@ -127,8 +127,8 @@ my (%ac_macros, %au_macros, %m4_builtins); sub handle_autoconf_macros () { # Get the builtins. - xsystem ("echo dumpdef | $m4 2>$tmp/m4.defs >/dev/null"); - my $m4_defs = new Autom4te::XFile "$tmp/m4.defs"; + xsystem ("echo dumpdef | $m4 2>" . shell_quote ("$tmp/m4.defs") . " >/dev/null"); + my $m4_defs = new Autom4te::XFile "< " . open_quote ("$tmp/m4.defs"); while ($_ = $m4_defs->getline) { $m4_builtins{$1} = 1 @@ -184,9 +184,9 @@ sub handle_autoconf_macros () # ac.m4 -- autoquoting definitions of the AC macros (M4sugar excluded). # unac.m4 -- undefine the AC macros. - my $ac_m4 = new Autom4te::XFile ">$tmp/ac.m4"; + my $ac_m4 = new Autom4te::XFile "> " . open_quote ("$tmp/ac.m4"); print $ac_m4 "# ac.m4 -- autoquoting definitions of the AC macros.\n"; - my $unac_m4 = new Autom4te::XFile ">$tmp/unac.m4"; + my $unac_m4 = new Autom4te::XFile "> " . open_quote ("$tmp/unac.m4"); print $unac_m4 "# unac.m4 -- undefine the AC macros.\n"; foreach (sort keys %ac_macros) { @@ -197,11 +197,11 @@ sub handle_autoconf_macros () # m4save.m4 -- save the m4 builtins. # unm4.m4 -- disable the m4 builtins. # m4.m4 -- enable the m4 builtins. - my $m4save_m4 = new Autom4te::XFile ">$tmp/m4save.m4"; + my $m4save_m4 = new Autom4te::XFile "> " . open_quote ("$tmp/m4save.m4"); print $m4save_m4 "# m4save.m4 -- save the m4 builtins.\n"; - my $unm4_m4 = new Autom4te::XFile ">$tmp/unm4.m4"; + my $unm4_m4 = new Autom4te::XFile "> " . open_quote ("$tmp/unm4.m4"); print $unm4_m4 "# unm4.m4 -- disable the m4 builtins.\n"; - my $m4_m4 = new Autom4te::XFile ">$tmp/m4.m4"; + my $m4_m4 = new Autom4te::XFile "> " . open_quote ("$tmp/m4.m4"); print $m4_m4 "# m4.m4 -- enable the m4 builtins.\n"; foreach (sort keys %m4_builtins) { @@ -220,8 +220,8 @@ parse_args; $autoconf .= " --debug" if $debug; $autoconf .= " --force" if $force; $autoconf .= " --verbose" if $verbose; -$autoconf .= join (' --include=', '', @include); -$autoconf .= join (' --prepend-include=', '', @prepend_include); +$autoconf .= join (' --include=', '', map { shell_quote ($_) } @include); +$autoconf .= join (' --prepend-include=', '', map { shell_quote ($_) } @prepend_include); mktmpdir ('au'); handle_autoconf_macros; @@ -233,7 +233,7 @@ my $au_changequote = # au.m4 -- definitions the AU macros. xsystem ("$autoconf --trace AU_DEFINE:'_au_defun(\@<:\@\$1\@:>\@, \@<:\@\$2\@:>\@)' --melt /dev/null " - . ">$tmp/au.m4"); + . ">" . shell_quote ("$tmp/au.m4")); @@ -247,7 +247,7 @@ foreach my $file (@ARGV) if ($file eq '-') { $file = "$tmp/stdin"; - system "cat >$file"; + system "cat >" . shell_quote ($file); } elsif (! -r "$file") { @@ -376,9 +376,9 @@ EOF $input_m4 =~ s/\$file/$file/g; # prepared input -- input, but reenables the quote before each AU macro. - open INPUT_M4, ">$tmp/input.m4" + open INPUT_M4, "> " . open_quote ("$tmp/input.m4") or error "cannot open: $!"; - open FILE, "<$file" + open FILE, "< " . open_quote ($file) or error "cannot open: $!"; print INPUT_M4 "$input_m4"; while (<FILE>) @@ -392,10 +392,10 @@ EOF or error "cannot close $tmp/input.m4: $!"; # Now ask m4 to perform the update. - xsystem ("$m4 --include=$tmp" - . join (' --include=', '', reverse (@prepend_include)) - . join (' --include=', '', @include) - . " $tmp/input.m4 >$tmp/updated"); + xsystem ("$m4 --include=" . shell_quote ($tmp) + . join (' --include=', '', map { shell_quote ($_) } reverse (@prepend_include)) + . join (' --include=', '', map { shell_quote ($_) } @include) + . " " . shell_quote ("$tmp/input.m4") . " > " . shell_quote ("$tmp/updated")); update_file ("$tmp/updated", "$file" eq "$tmp/stdin" ? '-' : "$file"); } |