]> git.saurik.com Git - apt.git/blobdiff - apt-inst/contrib/extracttar.cc
* apt-pkg/contrib/configuration.cc:
[apt.git] / apt-inst / contrib / extracttar.cc
index 68c871a5daff23d592f12da559b59eb8d062d53c..487027c3daccf16bcba2291f89a53adef758764a 100644 (file)
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#include <apt-pkg/extracttar.h>
+#include<config.h>
 
 
+#include <apt-pkg/extracttar.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/configuration.h>
-#include <system.h>
+#include <apt-pkg/macros.h>
 
 #include <stdlib.h>
 #include <unistd.h>
 #include <signal.h>
 #include <fcntl.h>
 #include <iostream>
 
 #include <stdlib.h>
 #include <unistd.h>
 #include <signal.h>
 #include <fcntl.h>
 #include <iostream>
+
 #include <apti18n.h>
                                                                        /*}}}*/
 
 #include <apti18n.h>
                                                                        /*}}}*/
 
@@ -195,10 +197,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 ||
       // 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"));
          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"));
@@ -208,14 +214,14 @@ bool ExtractTar::Go(pkgDirStream &Stream)
         Itm.Name = (char *)LastLongName.c_str();
       else
       {
         Itm.Name = (char *)LastLongName.c_str();
       else
       {
-        Tar->Name[sizeof(Tar->Name)] = 0;
+        Tar->Name[sizeof(Tar->Name)-1] = 0;
         Itm.Name = Tar->Name;
       }      
       if (Itm.Name[0] == '.' && Itm.Name[1] == '/' && Itm.Name[2] != 0)
         Itm.Name += 2;
       
       // Grab the link target
         Itm.Name = Tar->Name;
       }      
       if (Itm.Name[0] == '.' && Itm.Name[1] == '/' && Itm.Name[2] != 0)
         Itm.Name += 2;
       
       // Grab the link target
-      Tar->Name[sizeof(Tar->LinkName)] = 0;
+      Tar->Name[sizeof(Tar->LinkName)-1] = 0;
       Itm.LinkTarget = Tar->LinkName;
 
       if (LastLongLink.empty() == false)
       Itm.LinkTarget = Tar->LinkName;
 
       if (LastLongLink.empty() == false)
@@ -332,7 +338,7 @@ bool ExtractTar::Go(pkgDirStream &Stream)
       }
       
       // And finish up
       }
       
       // And finish up
-      if (Itm.Size >= 0 && BadRecord == false)
+      if (BadRecord == false)
         if (Stream.FinishedFile(Itm,Fd) == false)
            return false;
       
         if (Stream.FinishedFile(Itm,Fd) == false)
            return false;