summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-01-13 00:27:42 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-01-13 00:27:42 +0100
commitf688d1d3c90091c308ec979eabab511134810be9 (patch)
tree78374e93799608ea63ac2aac8d9dc0370d3b05be
parent1fc0d435891dc9496a71a680032918dab2372e6d (diff)
parent54f2f0a3e46e4369285be8c25912fd45413114c0 (diff)
* apt-inst/contrib/extracttar.cc:
- let apt-utils work with encoded tar headers if uid/gid are large. Thanks to Nobuhiro Hayashi for the patch! (Closes: #330162)
-rw-r--r--apt-inst/contrib/extracttar.cc12
-rw-r--r--apt-pkg/contrib/strutl.cc17
-rw-r--r--apt-pkg/contrib/strutl.h1
-rw-r--r--debian/changelog5
-rw-r--r--test/integration/deb-bug-330162-encoded-tar-header.debbin0 -> 544 bytes
-rwxr-xr-xtest/integration/test-bug-330162-encoded-tar-header11
6 files changed, 41 insertions, 5 deletions
diff --git a/apt-inst/contrib/extracttar.cc b/apt-inst/contrib/extracttar.cc
index 3d2788aaf..1a358d57e 100644
--- a/apt-inst/contrib/extracttar.cc
+++ b/apt-inst/contrib/extracttar.cc
@@ -195,10 +195,14 @@ bool ExtractTar::Go(pkgDirStream &Stream)
// Decode all of the fields
pkgDirStream::Item Itm;
if (StrToNum(Tar->Mode,Itm.Mode,sizeof(Tar->Mode),8) == false ||
- StrToNum(Tar->UserID,Itm.UID,sizeof(Tar->UserID),8) == false ||
- StrToNum(Tar->GroupID,Itm.GID,sizeof(Tar->GroupID),8) == false ||
- StrToNum(Tar->Size,Itm.Size,sizeof(Tar->Size),8) == false ||
- StrToNum(Tar->MTime,Itm.MTime,sizeof(Tar->MTime),8) == false ||
+ (Base256ToNum(Tar->UserID,Itm.UID,8) == false &&
+ StrToNum(Tar->UserID,Itm.UID,sizeof(Tar->UserID),8) == false) ||
+ (Base256ToNum(Tar->GroupID,Itm.GID,8) == false &&
+ StrToNum(Tar->GroupID,Itm.GID,sizeof(Tar->GroupID),8) == false) ||
+ (Base256ToNum(Tar->Size,Itm.Size,12) == false &&
+ StrToNum(Tar->Size,Itm.Size,sizeof(Tar->Size),8) == false) ||
+ (Base256ToNum(Tar->MTime,Itm.MTime,12) == false &&
+ StrToNum(Tar->MTime,Itm.MTime,sizeof(Tar->MTime),8) == false) ||
StrToNum(Tar->Major,Itm.Major,sizeof(Tar->Major),8) == false ||
StrToNum(Tar->Minor,Itm.Minor,sizeof(Tar->Minor),8) == false)
return _error->Error(_("Corrupted archive"));
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 987f4c3a4..f37045810 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -968,6 +968,23 @@ bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base)
return true;
}
/*}}}*/
+// Base256ToNum - Convert a fixed length binary to a number /*{{{*/
+// ---------------------------------------------------------------------
+/* This is used in decoding the 256bit encoded fixed length fields in
+ tar files */
+bool Base256ToNum(const char *Str,unsigned long &Res,unsigned int Len)
+{
+ if ((Str[0] & 0x80) == 0)
+ return false;
+ else
+ {
+ Res = Str[0] & 0x7F;
+ for(unsigned int i = 1; i < Len; ++i)
+ Res = (Res<<8) + Str[i];
+ return true;
+ }
+}
+ /*}}}*/
// HexDigit - Convert a hex character into an integer /*{{{*/
// ---------------------------------------------------------------------
/* Helper for Hex2Num */
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index a457ff047..6e0e253cf 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -52,6 +52,7 @@ string LookupTag(const string &Message,const char *Tag,const char *Default = 0);
int StringToBool(const string &Text,int Default = -1);
bool ReadMessages(int Fd, vector<string> &List);
bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0);
+bool Base256ToNum(const char *Str,unsigned long &Res,unsigned int Len);
bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length);
bool TokSplitString(char Tok,char *Input,char **List,
unsigned long ListMax);
diff --git a/debian/changelog b/debian/changelog
index 6028cc8f4..3a59ac171 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -29,8 +29,11 @@ apt (0.8.11+wheezy) unstable; urgency=low
Reinholdtsen for report and patch! (Closes: #607803)
* doc/apt.conf.5.xml:
- fix multipl{y,e} spelling error reported by Jakub Wilk (Closes: #607636)
+ * apt-inst/contrib/extracttar.cc:
+ - let apt-utils work with encoded tar headers if uid/gid are large.
+ Thanks to Nobuhiro Hayashi for the patch! (Closes: #330162)
- -- David Kalnischkies <kalnischkies@gmail.com> Wed, 12 Jan 2011 23:59:38 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com> Thu, 13 Jan 2011 00:25:32 +0100
apt (0.8.10) unstable; urgency=low
diff --git a/test/integration/deb-bug-330162-encoded-tar-header.deb b/test/integration/deb-bug-330162-encoded-tar-header.deb
new file mode 100644
index 000000000..f38b1aa70
--- /dev/null
+++ b/test/integration/deb-bug-330162-encoded-tar-header.deb
Binary files differ
diff --git a/test/integration/test-bug-330162-encoded-tar-header b/test/integration/test-bug-330162-encoded-tar-header
new file mode 100755
index 000000000..fa01e0379
--- /dev/null
+++ b/test/integration/test-bug-330162-encoded-tar-header
@@ -0,0 +1,11 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture "i386"
+
+msgtest 'Test apt-ftparchive with encoded tar header package'
+cp $TESTDIR/deb-bug-330162-encoded-tar-header.deb aptarchive/
+test -z "$(aptftparchive packages aptarchive/ 2>&1 | grep 'E:')" && msgpass || msgfail