Ver código fonte

Dpkg::Arch: Make debwildcard_to_debtriplet() more robust

Do not incorrectly match 'any' substrings in tuple elements. This is
not currently a problem but it could become one if we ever get an
architecture name with an 'any' substring on any of its components.
Guillem Jover 13 anos atrás
pai
commit
332fe40caf
2 arquivos alterados com 11 adições e 9 exclusões
  1. 2 1
      debian/changelog
  2. 9 8
      scripts/Dpkg/Arch.pm

+ 2 - 1
debian/changelog

@@ -1,6 +1,7 @@
 dpkg (1.17.2) UNRELEASED; urgency=low
 
-  *
+  * Make Dpkg::Arch debwildcard_to_debtriplet() more robust by matching
+    on exact 'any' strings, instead of substrings.
 
  -- Guillem Jover <guillem@debian.org>  Sun, 28 Jul 2013 15:06:29 +0200
 

+ 9 - 8
scripts/Dpkg/Arch.pm

@@ -365,18 +365,19 @@ sub gnutriplet_to_debarch($)
 
 sub debwildcard_to_debtriplet($)
 {
-    local ($_) = @_;
+    my ($arch) = @_;
+    my @tuple = split /-/, $arch, 3;
 
-    if (/any/) {
-	if (/^([^-]*)-([^-]*)-(.*)/) {
-	    return ($1, $2, $3);
-	} elsif (/^([^-]*)-([^-]*)$/) {
-	    return ('any', $1, $2);
+    if (any { $_ eq 'any' } @tuple) {
+	if (scalar @tuple == 3) {
+	    return @tuple;
+	} elsif (scalar @tuple == 2) {
+	    return ('any', @tuple);
 	} else {
-	    return ($_, $_, $_);
+	    return ('any', 'any', 'any');
 	}
     } else {
-	return debarch_to_debtriplet($_);
+	return debarch_to_debtriplet($arch);
     }
 }