Gentoo Archives: gentoo-commits

From: "Christian Ruppert (idl0r)" <idl0r@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoolkit r788 - in trunk/gentoolkit-dev: . src/ekeyword
Date: Fri, 02 Jul 2010 15:34:16
Message-Id: 20100702153413.1FD9B2CE15@corvid.gentoo.org
1 Author: idl0r
2 Date: 2010-07-02 15:34:12 +0000 (Fri, 02 Jul 2010)
3 New Revision: 788
4
5 Modified:
6 trunk/gentoolkit-dev/ChangeLog
7 trunk/gentoolkit-dev/src/ekeyword/ekeyword
8 Log:
9 Validate user input/arch, bug 326029.
10
11
12 Modified: trunk/gentoolkit-dev/ChangeLog
13 ===================================================================
14 --- trunk/gentoolkit-dev/ChangeLog 2010-07-02 15:30:13 UTC (rev 787)
15 +++ trunk/gentoolkit-dev/ChangeLog 2010-07-02 15:34:12 UTC (rev 788)
16 @@ -9,6 +9,7 @@
17 get_architectures reads $PORTDIR/profiles/arch.list and adds all
18 available architectures to the %ARCH hash which can be used for
19 validation.
20 + Validate user input/arch, bug 326029.
21
22 2010-05-17: Christian Ruppert <idl0r@g.o>
23 * echangelog: Update copyright in other files too (except binaries and
24
25 Modified: trunk/gentoolkit-dev/src/ekeyword/ekeyword
26 ===================================================================
27 --- trunk/gentoolkit-dev/src/ekeyword/ekeyword 2010-07-02 15:30:13 UTC (rev 787)
28 +++ trunk/gentoolkit-dev/src/ekeyword/ekeyword 2010-07-02 15:34:12 UTC (rev 788)
29 @@ -13,6 +13,9 @@
30 my ($kw_re) = '^(?:([-~^]?)(\w[\w-]*)|([-^]\*))$';
31 my (@kw);
32
33 +my $PORTDIR = undef;
34 +my %ARCH = ();
35 +
36 sub file_parse {
37 my $fname = shift;
38 my @content = ();
39 @@ -71,9 +74,21 @@
40 die "I don't understand $a\n";
41 }
42
43 +$PORTDIR = get_portdir();
44 +get_architectures();
45 +
46 my $files = 0;
47 for my $f (@ARGV) {
48 - if ($f =~ /$kw_re/o) {
49 + if ($f =~ m/$kw_re/o) {
50 + my $arch = $2;
51 +
52 + if(length($arch) > 0 && $arch ne "all") {
53 + if(!defined($ARCH{$arch})) {
54 + printf STDERR ("'%s' is an unknown architecture! skipping...\n", $arch);
55 + next;
56 + }
57 + }
58 +
59 push @kw, $f;
60 next;
61 }