]> git.saurik.com Git - apt.git/commitdiff
Permit base256 encoded value in the numeric field of tar header.
authorNobuhiro Hayashi <nobuhiro.hayashi@gmail.com>
Fri, 3 Dec 2010 03:09:09 +0000 (12:09 +0900)
committerNobuhiro Hayashi <nobuhiro.hayashi@gmail.com>
Fri, 3 Dec 2010 03:09:09 +0000 (12:09 +0900)
apt-inst/contrib/extracttar.cc
apt-pkg/contrib/strutl.cc
apt-pkg/contrib/strutl.h

index 3d2788aafbdf18070e8c3747b962213471be1188..1a358d57e6fb34280edef6136d74d1738a088ccd 100644 (file)
@@ -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"));
index 987f4c3a48414ec99cab139feccc8d99841b9425..daf87c87fa30ffb4e338bef98261cddba2546b53 100644 (file)
@@ -968,6 +968,24 @@ 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 Len)
+{
+   int i;
+   if ((Str[0] & 0x80) == 0)
+      return false;
+   else
+   {
+      Res = Str[0] & 0x7F;
+      for(i=1; i<Len; i++)
+         Res = (Res<<8) + Str[i];
+      return true;
+   }
+}
+                                                                       /*}}}*/
 // HexDigit - Convert a hex character into an integer                  /*{{{*/
 // ---------------------------------------------------------------------
 /* Helper for Hex2Num */
index a457ff047da314d428bca60455ebfac643e192b2..591c992d035fbe649bc75b1d116ed9b83385b8bf 100644 (file)
@@ -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 Len);
 bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length);
 bool TokSplitString(char Tok,char *Input,char **List,
                    unsigned long ListMax);