Explorar el Código

VersionHash: Do not skip too long dependency lines

If the dependency line does not contain spaces in the repository
but does in the dpkg status file (because dpkg normalized the
dependency list), the dpkg line might be longer than the line
in the repository. If it now happens to be longer than 1024
characters, it would be skipped, causing the hashes to be
out of date.

Note that we have to bump the minor cache version again as
this changes the format slightly, and we might get mismatches
with an older src cache otherwise.

Fixes Debian/apt#23
Julian Andres Klode hace 9 años
padre
commit
708e2f1fe9

+ 2 - 2
apt-pkg/deb/deblistparser.cc

@@ -344,14 +344,14 @@ unsigned short debListParser::VersionHash()
    {
       const char *Start;
       const char *End;
-      if (Section.Find(I,Start,End) == false || End - Start >= (signed)sizeof(S))
+      if (Section.Find(I,Start,End) == false)
 	 continue;
       
       /* Strip out any spaces from the text, this undoes dpkgs reformatting
          of certain fields. dpkg also has the rather interesting notion of
          reformatting depends operators < -> <= */
       char *J = S;
-      for (; Start != End; ++Start)
+      for (; Start != End && (J - S) < sizeof(S); ++Start)
       {
 	 if (isspace_ascii(*Start) != 0)
 	    continue;

+ 1 - 1
apt-pkg/pkgcache.cc

@@ -59,7 +59,7 @@ pkgCache::Header::Header()
    /* Whenever the structures change the major version should be bumped,
       whenever the generator changes the minor version should be bumped. */
    APT_HEADER_SET(MajorVersion, 10);
-   APT_HEADER_SET(MinorVersion, 6);
+   APT_HEADER_SET(MinorVersion, 7);
    APT_HEADER_SET(Dirty, false);
 
    APT_HEADER_SET(HeaderSz, sizeof(pkgCache::Header));

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 17 - 0
test/integration/Packages-github-23-too-long-dependency-line


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 12 - 0
test/integration/status-github-23-too-long-dependency-line


+ 17 - 0
test/integration/test-github-23-too-long-dependency-line

@@ -0,0 +1,17 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+setupenvironment
+configarchitecture "amd64"
+setupaptarchive
+
+
+testsuccessequal "network-manager-strongswan:
+  Installed: 1.3.1-14
+  Candidate: 1.3.1-14
+  Version table:
+ *** 1.3.1-14 500
+        500 file:${TMPWORKINGDIRECTORY}/aptarchive  Packages
+        100 ${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status" aptcache policy network-manager-strongswan