]> git.saurik.com Git - apt.git/commitdiff
VersionHash: Do not skip too long dependency lines
authorJulian Andres Klode <jak@debian.org>
Sun, 18 Sep 2016 11:24:35 +0000 (13:24 +0200)
committerJulian Andres Klode <jak@debian.org>
Sun, 18 Sep 2016 12:17:17 +0000 (14:17 +0200)
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

apt-pkg/deb/deblistparser.cc
apt-pkg/pkgcache.cc
test/integration/Packages-github-23-too-long-dependency-line [new file with mode: 0644]
test/integration/status-github-23-too-long-dependency-line [new file with mode: 0644]
test/integration/test-github-23-too-long-dependency-line [new file with mode: 0755]

index f7f64debdda1de3b75dd1c68ede503e24765e720..99e806470e29a50b182cb32df5fefe28d162a8e8 100644 (file)
@@ -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;
index 27a0ba0351f60ea0b716da96d40fb3c13bea346e..b4c232f8c15dc218120aed0aff44401bcf844156 100644 (file)
@@ -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));
diff --git a/test/integration/Packages-github-23-too-long-dependency-line b/test/integration/Packages-github-23-too-long-dependency-line
new file mode 100644 (file)
index 0000000..967d6ed
--- /dev/null
@@ -0,0 +1,17 @@
+Package: network-manager-strongswan
+Architecture: amd64
+Version: 1.3.1-14
+Priority: extra
+Section: net
+Maintainer: Jean-Christophe Manciot <manciot.jeanchristophe@gmail.com>
+Installed-Size: 256
+Provides: network-manager-strongswan
+Depends: libart-2.0-2,libatk1.0-0,libavahi-client3,libavahi-common3,libavahi-glib1,libbonobo2-0,libbonoboui2-0,libc6,libcairo2,libcanberra0,libdatrie1,libdbus-1-3,libdbus-glib-1-2,libexpat1,libffi6,libfontconfig1,libfreetype6,libgail18,libgconf-2-4,libgcrypt20,libgdk-pixbuf2.0-0,libglib2.0-0,libglib2.0-0-dbg,libglib2.0-0-refdbg,libgmp10,libgnome-2-0,libgnomecanvas2-0,libgnome-keyring0,libgnomeui-0,libgnomevfs2-0,libgnutls30,libgpg-error0,libgraphite2-3,libgtk2.0-0,libharfbuzz0b,libhogweed4,libice6,libidn11,libltdl7,liblzma5,libnettle6,libnm-glib-vpn1,libnm-util2,libogg0,liborbit-2-0,libp11-kit0,libpango-1.0-0,libpangocairo-1.0-0,libpangoft2-1.0-0,libpcre3,libpixman-1-0,libpng12-0,libpopt0,libselinux1,libsm6,libsystemd0,libtasn1-6,libtdb1,libthai0,libuuid1,libvorbis0a,libvorbisfile3,libx11-6,libxau6,libxcb1,libxcb-render0,libxcb-shm0,libxcomposite1,libxcursor1,libxdamage1,libxdmcp6,libxext6,libxfixes3,libxi6,libxinerama1,libxml2,libxrandr2,libxrender1,zlib1g
+Filename: dists/xenial/stable/binary-amd64/network-manager-strongswan_1.3.1-14_amd64.deb
+Size: 34642
+MD5sum: 6f4482cb417e4c884a6715f315695937
+SHA1: 07dc0377c365f6ccb67d8e135ab32f27b5b5774d
+SHA256: e526bc8c6c8b29dc28e5783ad076119d3be0e804779b3ca3a68959b7ac23f163
+SHA512: 6e2eb65023301dcaf1813a3c5686a82bdb61bdd3597e1976e067e06a0b0eee96e6d2a2d8b890bf37b8120eb9ff671a5ac4ee49de83feb3199afeab2893b8dec6
+Description: This package provides an IKEv2 IPSec VPN plugin for strongswan
+Description-md5: 31abf1e375284c7ee36f25bf936125f1
diff --git a/test/integration/status-github-23-too-long-dependency-line b/test/integration/status-github-23-too-long-dependency-line
new file mode 100644 (file)
index 0000000..7378c99
--- /dev/null
@@ -0,0 +1,12 @@
+Package: network-manager-strongswan
+Status: install ok installed
+Priority: extra
+Section: net
+Installed-Size: 256
+Maintainer: Jean-Christophe Manciot <manciot.jeanchristophe@gmail.com>
+Architecture: amd64
+Version: 1.3.1-14
+Provides: network-manager-strongswan
+Depends: libart-2.0-2, libatk1.0-0, libavahi-client3, libavahi-common3, libavahi-glib1, libbonobo2-0, libbonoboui2-0, libc6, libcairo2, libcanberra0, libdatrie1, libdbus-1-3, libdbus-glib-1-2, libexpat1, libffi6, libfontconfig1, libfreetype6, libgail18, libgconf-2-4, libgcrypt20, libgdk-pixbuf2.0-0, libglib2.0-0, libglib2.0-0-dbg, libglib2.0-0-refdbg, libgmp10, libgnome-2-0, libgnomecanvas2-0, libgnome-keyring0, libgnomeui-0, libgnomevfs2-0, libgnutls30, libgpg-error0, libgraphite2-3, libgtk2.0-0, libharfbuzz0b, libhogweed4, libice6, libidn11, libltdl7, liblzma5, libnettle6, libnm-glib-vpn1, libnm-util2, libogg0, liborbit-2-0, libp11-kit0, libpango-1.0-0, libpangocairo-1.0-0, libpangoft2-1.0-0, libpcre3, libpixman-1-0, libpng12-0, libpopt0, libselinux1, libsm6, libsystemd0, libtasn1-6, libtdb1, libthai0, libuuid1, libvorbis0a, libvorbisfile3, libx11-6, libxau6, libxcb1, libxcb-render0, libxcb-shm0, libxcomposite1, libxcursor1, libxdamage1, libxdmcp6, libxext6, libxfixes3, libxi6, libxinerama1, libxml2, libxrandr2, libxrender1, zlib1g
+Description: This package provides an IKEv2 IPSec VPN plugin for strongswan
+Description-md5: 31abf1e375284c7ee36f25bf936125f1
diff --git a/test/integration/test-github-23-too-long-dependency-line b/test/integration/test-github-23-too-long-dependency-line
new file mode 100755 (executable)
index 0000000..d514303
--- /dev/null
@@ -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