From: idl0r Date: Fri, 2 Jul 2010 15:34:12 +0000 (-0000) Subject: Validate user input/arch, bug 326029. X-Git-Tag: gentoolkit-dev-0.2.7~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9f6a2a4ccefb0ddd3bbb4accc69583802ee9ff85;p=gentoolkit.git Validate user input/arch, bug 326029. svn path=/trunk/gentoolkit-dev/; revision=788 --- diff --git a/ChangeLog b/ChangeLog index 8e4d904..0c7361d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ get_architectures reads $PORTDIR/profiles/arch.list and adds all available architectures to the %ARCH hash which can be used for validation. + Validate user input/arch, bug 326029. 2010-05-17: Christian Ruppert * echangelog: Update copyright in other files too (except binaries and diff --git a/src/ekeyword/ekeyword b/src/ekeyword/ekeyword index dab5189..3024f0a 100755 --- a/src/ekeyword/ekeyword +++ b/src/ekeyword/ekeyword @@ -13,6 +13,9 @@ my ($kw_re) = '^(?:([-~^]?)(\w[\w-]*)|([-^]\*))$'; my (@kw); +my $PORTDIR = undef; +my %ARCH = (); + sub file_parse { my $fname = shift; my @content = (); @@ -71,9 +74,21 @@ for my $a (@ARGV) { die "I don't understand $a\n"; } +$PORTDIR = get_portdir(); +get_architectures(); + my $files = 0; for my $f (@ARGV) { - if ($f =~ /$kw_re/o) { + if ($f =~ m/$kw_re/o) { + my $arch = $2; + + if(length($arch) > 0 && $arch ne "all") { + if(!defined($ARCH{$arch})) { + printf STDERR ("'%s' is an unknown architecture! skipping...\n", $arch); + next; + } + } + push @kw, $f; next; }