reassign 571601 apt tag 571601 confirmed thanks On Fri, Feb 26, 2010 at 12:35:29PM +0100, Filippo Giunchedi wrote: > Package: python-apt > Version: 0.7.93.1 > Severity: normal > > Hi, > while investigating #571470 (which shows similar symptoms but different > results) I incurred into an unexpected behavior of TagFile.offset and > TagFile.jump, specifically one would expect that after jump reading back the > offset would yield the same offset being jumped to, instead it seems to return > the next section (and not always). I used the attached test, running it on a > Packages file (any will do it seems, one from sid for example): [...] > of course the number of sections yielded is lower than the Packages file. > Is this documented/wanted/expected? Seems rather odd.
Even the following two yield different results; although one would expect
the file to always jump to 0.
(1) step(); jump(0); step();
(2) step(); jump(0); jump(0); step();
The first one would yield the same section in all three actions; whereas
the second one would step one section forward. I attached a C++ test case
for that one.
But both cases are bugs in apt itself, and not specific to python-apt. In
your case, jumping to offset - 1 might help (or to tagfile.offset -
len(section)).
My issue could probably be fixed by adding
// Not jumping at all.
if (Offset == iOffset)
return true;
to the top of Jump() in tagfile.cc; but I believe both issues are
related and there is a more complicated issue somewhere in the
code.
--
Julian Andres Klode - Debian Developer, Ubuntu Member
See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
#include <cstdio>
#include <iostream>
#include <apt-pkg/tagfile.h>
int main(int argc, char *argv[]) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << "file \n";
return 1;
}
FileFd fd(argv[1],FileFd::ReadOnly);
pkgTagFile file(&fd);
pkgTagSection section;
file.Step(section);
string first = section.FindS("MD5Sum");
std::cout << first << "\n";
file.Jump(section, 0);
file.Step(section);
string second = section.FindS("MD5Sum");
std::cout << second << "\n";
file.Jump(section, 0);
file.Jump(section, 0);
file.Step(section);
string third = section.FindS("MD5Sum");
std::cout << third << "\n";
if (first != second || second != third)
std::cout << "FAIL\n";
return ((first == second && second == third) ? 0 : 1);
}
pgp6HEH1BiYZY.pgp
Description: PGP signature

