aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <mricon@kernel.org>2012-04-20 16:03:19 -0400
committerKonstantin Ryabitsev <mricon@kernel.org>2012-04-20 16:03:19 -0400
commit500ded5b55c0e5e3ab9214cc0b4d27631885dafd (patch)
tree8b147eb2fe918cd9ebe3181d5c0994c48de58013
parent9f075e7d367c5180bd7070e5ae3f170c89b5fc20 (diff)
downloadkup-500ded5b55c0e5e3ab9214cc0b4d27631885dafd.tar.gz
Don't use magic to guess the format.
Remove magic-guessing logic from kup client, as it was interfering with people's ability to upload gzipped kernel images. We're now being dumb about it -- we only rely on the extension to guess whether the server needs to uncompress the contents before verifying sig.
-rw-r--r--ChangeLog6
-rwxr-xr-xkup47
2 files changed, 14 insertions, 39 deletions
diff --git a/ChangeLog b/ChangeLog
index f2c169b..dd9a222 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-04-20 Konstantin Ryabitsev <mricon@kernel.org> - master
+ * Remove magic-guessing logic from kup client, as it was interfering with
+ people's ability to upload gzipped kernel images. We're now being dumb
+ about it -- we only rely on the extension to guess whether the server
+ needs to uncompress the contents before verifying sig.
+
2012-02-13 Konstantin Ryabitsev <mricon@kernel.org> - 0.3.3
* Allow specifying the key to use for gpg-sign-all.
* Remove kup.kernel.org as the default host setting.
diff --git a/kup b/kup
index 5896290..b00dbb3 100755
--- a/kup
+++ b/kup
@@ -292,44 +292,18 @@ sub command(@)
}
}
-sub get_data_format($)
-{
- my($data) = @_;
-
- my $magic2 = substr($data, 0, 2);
- my $magic4 = substr($data, 0, 4);
- my $magic6 = substr($data, 0, 6);
-
- my $fmt = '%'; # Meaning straight binary
-
- if ($magic2 eq "\037\213") {
- $fmt = 'gz';
- } elsif ($magic4 =~ /^BZh[1-9]$/) {
- # The primary bzip2 magic is so crappy, so look
- # for the magic number of the first packet
- # (either a compression packet or an end of file packet.)
- # Funny enough, the magics on the packets are better
- # than the magics on the file format, and even so
- # they managed to pick a magic for the compression
- # packet which has no non-ASCII bytes in it...
-
- my $submagic = substr($data, 4, 6);
-
- if ($submagic eq "\x31\x41\x59\x26\x53\x59" ||
- $submagic eq "\x17\x72\x45\x38\x50\x90") {
- $fmt = 'bz2';
- }
- } elsif ($magic6 eq "\x{fd}7zXZ\0") {
- $fmt = 'xz';
- }
-
- return $fmt;
-}
-
sub cat_file($$$)
{
my($cmd, $file, $fmt) = @_;
+ if (!defined($fmt)) {
+ if ($file =~ /\.((gz|bz2|xz))$/) {
+ $fmt = $1;
+ } else {
+ $fmt = '%';
+ }
+ }
+
my $data;
open($data, '<', $file)
or die "$0: cannot open: $file: $!\n";
@@ -361,11 +335,6 @@ sub cat_file($$$)
die "$0: premature end of data (file changed?): $file\n";
}
- if (!defined($fmt)) {
- $fmt = get_data_format($blk);
- command($cmd, $size, $fmt);
- }
-
print $blk;
$size -= $len;
}