aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoridl0r <idl0r@gentoo.org>2010-07-02 15:34:12 +0000
committeridl0r <idl0r@gentoo.org>2010-07-02 15:34:12 +0000
commit9f6a2a4ccefb0ddd3bbb4accc69583802ee9ff85 (patch)
treeef38bff7ac1d03cc960f8c96d1f9c307f938f5c8
parentekeyword: Add file_parse, get_portdir and get_architectures functions. (diff)
downloadgentoolkit-9f6a2a4ccefb0ddd3bbb4accc69583802ee9ff85.tar.gz
gentoolkit-9f6a2a4ccefb0ddd3bbb4accc69583802ee9ff85.tar.bz2
gentoolkit-9f6a2a4ccefb0ddd3bbb4accc69583802ee9ff85.zip
Validate user input/arch, bug 326029.
svn path=/trunk/gentoolkit-dev/; revision=788
-rw-r--r--ChangeLog1
-rwxr-xr-xsrc/ekeyword/ekeyword17
2 files changed, 17 insertions, 1 deletions
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 <idl0r@gentoo.org>
* 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;
}