Merge remote-tracking branch 'donkult/debian/sid' into debian/sid
[ntk/apt.git] / apt-pkg / indexrecords.cc
index cdb9250..8a72ca1 100644 (file)
@@ -12,6 +12,7 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/hashes.h>
+#include <apt-pkg/gpgv.h>
 
 #include <sys/stat.h>
 #include <clocale>
@@ -44,7 +45,10 @@ time_t indexRecords::GetValidUntil() const
 
 const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
 {
-   return Entries[MetaKey];
+   std::map<std::string, indexRecords::checkSum* >::const_iterator sum = Entries.find(MetaKey);
+   if (sum == Entries.end())
+      return NULL;
+   return sum->second;
 }
 
 bool indexRecords::Exists(string const &MetaKey) const
@@ -54,8 +58,11 @@ bool indexRecords::Exists(string const &MetaKey) const
 
 bool indexRecords::Load(const string Filename)                         /*{{{*/
 {
-   FileFd Fd(Filename, FileFd::ReadOnly);
-   pkgTagFile TagFile(&Fd, Fd.Size() + 256); // XXX
+   FileFd Fd;
+   if (OpenMaybeClearSignedFile(Filename, Fd) == false)
+      return false;
+
+   pkgTagFile TagFile(&Fd, Fd.Size());
    if (_error->PendingError() == true)
    {
       strprintf(ErrorText, _("Unable to parse Release file %s"),Filename.c_str());
@@ -64,16 +71,11 @@ bool indexRecords::Load(const string Filename)                              /*{{{*/
 
    pkgTagSection Section;
    const char *Start, *End;
-   // Skip over sections beginning with ----- as this is an idicator for clearsigns
-   do {
-      if (TagFile.Step(Section) == false)
-      {
-        strprintf(ErrorText, _("No sections in Release file %s"), Filename.c_str());
-        return false;
-      }
-
-      Section.Get (Start, End, 0);
-   } while (End - Start > 5 && strncmp(Start, "-----", 5) == 0);
+   if (TagFile.Step(Section) == false)
+   {
+      strprintf(ErrorText, _("No sections in Release file %s"), Filename.c_str());
+      return false;
+   }
 
    Suite = Section.FindS("Suite");
    Dist = Section.FindS("Codename");
@@ -170,7 +172,7 @@ bool indexRecords::parseSumData(const char *&Start, const char *End,        /*{{{*/
    Hash = "";
    Size = 0;
    /* Skip over the first blank */
-   while ((*Start == '\t' || *Start == ' ' || *Start == '\n')
+   while ((*Start == '\t' || *Start == ' ' || *Start == '\n' || *Start == '\r')
          && Start < End)
       Start++;
    if (Start >= End)
@@ -212,7 +214,8 @@ bool indexRecords::parseSumData(const char *&Start, const char *End,        /*{{{*/
    
    EntryEnd = Start;
    /* Find the end of the third entry (the filename) */
-   while ((*EntryEnd != '\t' && *EntryEnd != ' ' && *EntryEnd != '\n')
+   while ((*EntryEnd != '\t' && *EntryEnd != ' ' && 
+           *EntryEnd != '\n' && *EntryEnd != '\r')
          && EntryEnd < End)
       EntryEnd++;