]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
Replace <> with <<>>
authorMichal Sojka <michal.sojka@cvut.cz>
Fri, 22 Oct 2021 12:19:30 +0000 (14:19 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Fri, 22 Oct 2021 12:19:30 +0000 (14:19 +0200)
The reason is that <> can be dangerous. From Perl documentation:

    Since the null filehandle uses the two argument form of "open" in
    perlfunc it interprets special characters, so if you have a script like
    this:

while (<>) {
    print;
}

    and call it with "perl dangerous.pl 'rm -rfv *|'", it actually opens a
    pipe, executes the "rm" command and reads "rm"'s output from that pipe.
    If you want all items in @ARGV to be interpreted as file names, you can
    use the module "ARGV::readonly" from CPAN, or use the double diamond
    bracket:

while (<<>>) {
    print;
}

    Using double angle brackets inside of a while causes the open to use
    the three argument form (with the second argument being "<"), so all
    arguments in "ARGV" are treated as literal filenames (including "-").
    (Note that for convenience, if you use "<<>>" and if @ARGV is empty, it
    will still read from the standard input.)

novaboot

index 7fa381605f054bbce477bf74207d9837f8ada11b..0e888816369aab168f88a85a561869dd0ff0c96a 100755 (executable)
--- a/novaboot
+++ b/novaboot
@@ -357,7 +357,7 @@ my $EOF;
 my $last_fn = '';
 my ($modules, $variables, $generated, $copy, $chainload, $continuation) = ([], {}, [], []);
 my $skip_reading = defined($on_opt) || defined($off_opt);
-while (!$skip_reading && ($_ = <>)) {
+while (!$skip_reading && ($_ = <<>>)) {
     if ($ARGV ne $last_fn) { # New script
        die "Missing EOF in $last_fn" if $file;
        die "Unfinished line in $last_fn" if $continuation;