From ec8ff2e14f4f6d69282b21def9f2f0fc64116b21 Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Tue, 4 Aug 2020 21:10:27 +0200 Subject: untaint arguments --- challenge-072/jo-37/perl/ch-2.pl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'challenge-072') diff --git a/challenge-072/jo-37/perl/ch-2.pl b/challenge-072/jo-37/perl/ch-2.pl index 423ed6ca80..95a529b5a5 100755 --- a/challenge-072/jo-37/perl/ch-2.pl +++ b/challenge-072/jo-37/perl/ch-2.pl @@ -1,10 +1,12 @@ -#!/usr/bin/perl +#!/usr/bin/perl -T use strict; use warnings; sub print_range { - my ($file, $A, $B) = (shift, shift() + 0, shift() + 0); + my $file = shift; + my ($A) = shift =~ /^(\d+)/; + my ($B) = shift =~ /^(\d+)/; return if !$file || $A < 1 || $B < $A; @@ -18,4 +20,8 @@ EOS close $fh or warn "$file: $!\n"; } -print_range 'ch-2.in', 3, 5; +if (@ARGV) { + print_range @ARGV; +} else { + print_range 'ch-2.in', 3, 5; +} -- cgit