X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/3573e286ba001ef30f4871f3ed2e17ea905d6404..7be8c02360bdb9bd7f59b087da874f88af2a7206:/apt-inst/contrib/extracttar.cc?ds=sidebyside diff --git a/apt-inst/contrib/extracttar.cc b/apt-inst/contrib/extracttar.cc index d6da802fe..487027c3d 100644 --- a/apt-inst/contrib/extracttar.cc +++ b/apt-inst/contrib/extracttar.cc @@ -16,21 +16,20 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#ifdef __GNUG__ -#pragma implementation "apt-pkg/extracttar.h" -#endif -#include +#include +#include #include #include #include -#include +#include #include #include #include #include #include + #include /*}}}*/ @@ -136,7 +135,8 @@ bool ExtractTar::StartGzip() const char *Args[3]; string confvar = string("dir::bin::") + DecompressProg; - Args[0] = _config->Find(confvar.c_str(),DecompressProg.c_str()).c_str(); + string argv0 = _config->Find(confvar.c_str(),DecompressProg.c_str()); + Args[0] = argv0.c_str(); Args[1] = "-d"; Args[2] = 0; execvp(Args[0],(char **)Args); @@ -197,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 || - 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")); @@ -210,14 +214,14 @@ bool ExtractTar::Go(pkgDirStream &Stream) 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 - Tar->Name[sizeof(Tar->LinkName)] = 0; + Tar->Name[sizeof(Tar->LinkName)-1] = 0; Itm.LinkTarget = Tar->LinkName; if (LastLongLink.empty() == false) @@ -334,7 +338,7 @@ bool ExtractTar::Go(pkgDirStream &Stream) } // And finish up - if (Itm.Size != 0 && BadRecord == false) + if (BadRecord == false) if (Stream.FinishedFile(Itm,Fd) == false) return false;