瀏覽代碼

apt-pkg/acquire-item.cc: only test packages file for correctness if its not empty (its ok to have empty packages files)

Michael Vogt 15 年之前
父節點
當前提交
a0c3110e03
共有 1 個文件被更改,包括 14 次插入11 次删除
  1. 14 11
      apt-pkg/acquire-item.cc

+ 14 - 11
apt-pkg/acquire-item.cc

@@ -910,17 +910,20 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash,
 	 pkgTagSection sec;
 	 pkgTagFile tag(&fd);
 
-	 if (_error->PendingError() || !tag.Step(sec)) {
-	    Status = StatError;
-	    _error->DumpErrors();
-	    Rename(DestFile,DestFile + ".FAILED");
-	    return;
-	 } else if (!sec.Exists("Package")) {
-	    Status = StatError;
-	    ErrorText = ("Encountered a section with no Package: header");
-	    Rename(DestFile,DestFile + ".FAILED");
-	    return;
-	 }
+         // Only test for correctness if the file is not empty (empty is ok)
+         if (fd.Size() > 0) {
+            if (_error->PendingError() || !tag.Step(sec)) {
+               Status = StatError;
+               _error->DumpErrors();
+               Rename(DestFile,DestFile + ".FAILED");
+               return;
+            } else if (!sec.Exists("Package")) {
+               Status = StatError;
+               ErrorText = ("Encountered a section with no Package: header");
+               Rename(DestFile,DestFile + ".FAILED");
+               return;
+            }
+         }
       }
        
       // Done, move it into position