Bug#192403: Fails to parse empty Packages file (E: Encountered a section with no Package: header)
I sat down to reproduce this, and it seems that it works perfectly well with
an empty file. The problem does occur, however, with a file containing only
a newline.
My guess was that the apt-build Packages files, which triggered this bug for
most of the submitters, also contain only a newline. So I installed
apt-build to find out (which kindly diverted my gcc and all sorts of other
fun stuff). The result:
Reading Package Lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/_var_cache_apt-build_repository_dists_apt-build_main_binary-i386_Packages
E: The package lists or status file could not be parsed or opened.
zsh: exit 100 sudo apt-get update
mizar:[~irc/lib/apt/lists] ls -l /var/lib/apt/lists/_var_cache_apt-build_repository_dists_apt-build_main_binary-i386_Packages
-rw-r--r-- 1 root root 1 2003-06-23 00:26 /var/lib/apt/lists/_var_cache_apt-build_repository_dists_apt-build_main_binary-i386_Packages
mizar:[~irc/lib/apt/lists] wc -l /var/lib/apt/lists/_var_cache_apt-build_repository_dists_apt-build_main_binary-i386_Packages
1 /var/lib/apt/lists/_var_cache_apt-build_repository_dists_apt-build_main_binary-i386_Packages
So, should a Packages file with only whitespace be as valid as an empty one?
If not, this is an apt-build bug.
At any rate, this fixes the problem for me:
Index: apt-pkg/tagfile.cc
===================================================================
RCS file: /cvs/deity/apt/apt-pkg/tagfile.cc,v
retrieving revision 1.37
diff -u -u -r1.37 tagfile.cc
--- apt-pkg/tagfile.cc 19 May 2003 17:13:57 -0000 1.37
+++ apt-pkg/tagfile.cc 23 Jun 2003 04:29:46 -0000
@@ -103,7 +103,7 @@
if (Done == true)
{
- if (EndSize <= 3 && Actual == 0)
+ if (EndSize <= 3)
return false;
if (Size - (End - Buffer) < 4)
return true;
However, this is essentially reverting version 1.33 of tagfile.cc:
revision 1.33
date: 2002/05/30 04:19:48; author: jgg; state: Exp; lines: +3 -3
Fix last fix, make sure we read something before giving up
So presumably this change was made for a reason.
--
- mdz
Reply to: