From ae6ea526d65eb560b825677e8aac4a3fa15934e4 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 27 Jul 2011 23:50:55 +0200 Subject: * apt-pkg/deb/deblistparser.cc: - do not assume that the last char on a line is a \n (Closes: #633350) --- apt-pkg/deb/deblistparser.cc | 6 ++++- debian/changelog | 8 +++++++ ...est-bug-633350-do-not-kill-last-char-in-Release | 27 ++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 test/integration/test-bug-633350-do-not-kill-last-char-in-Release diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 651fa2a81..fd5a1e475 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -805,6 +805,10 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI, for (++dataStart; *dataStart == ' '; ++dataStart); char* dataEnd = dataStart; for (++dataEnd; *dataEnd != '\0'; ++dataEnd); + // The last char should be a newline, but we can never be sure: #633350 + char* lineEnd = dataEnd; + for (--lineEnd; *lineEnd == '\r' || *lineEnd == '\n'; --lineEnd); + ++lineEnd; // which datastorage need to be updated map_ptrloc* writeTo = NULL; @@ -819,7 +823,7 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI, APT_PARSER_WRITETO(FileI->Label, "Label") #undef APT_PARSER_WRITETO #define APT_PARSER_FLAGIT(X) else if (strncmp(#X, buffer, len) == 0) \ - pkgTagSection::FindFlag(FileI->Flags, pkgCache::Flag:: X, dataStart, dataEnd-1); + pkgTagSection::FindFlag(FileI->Flags, pkgCache::Flag:: X, dataStart, lineEnd); APT_PARSER_FLAGIT(NotAutomatic) APT_PARSER_FLAGIT(ButAutomaticUpgrades) #undef APT_PARSER_FLAGIT diff --git a/debian/changelog b/debian/changelog index 1eeb99b98..3f723f2d6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +apt (0.8.15.5) UNRELEASED; urgency=low + + [ David Kalnischkies ] + * apt-pkg/deb/deblistparser.cc: + - do not assume that the last char on a line is a \n (Closes: #633350) + + -- David Kalnischkies Wed, 27 Jul 2011 23:25:45 +0200 + apt (0.8.15.4) unstable; urgency=low [ David Miller ] diff --git a/test/integration/test-bug-633350-do-not-kill-last-char-in-Release b/test/integration/test-bug-633350-do-not-kill-last-char-in-Release new file mode 100755 index 000000000..3d3835507 --- /dev/null +++ b/test/integration/test-bug-633350-do-not-kill-last-char-in-Release @@ -0,0 +1,27 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' + +insertpackage 'unstable' 'cool' 'amd64' '1.0' + +setupaptarchive 2> /dev/null + +echo 'NotAutomatic: yes' >> aptarchive/dists/unstable/Release + +signreleasefiles +find aptarchive/dists -name 'InRelease' -delete + +rm -rf rootdir/var/lib/apt/lists rootdir/var/cache/apt + +OUTPUT="$(aptget update 2>&1)" +msgtest 'Check that parsing happens without warnings' 'with missing newline' +if echo "${OUTPUT}" | grep '^W:' > /dev/null; then + msgfail + echo "${OUTPUT}" +else + msgpass +fi -- cgit v1.2.3 From fc15861a405a0b0483bb8989e6a43215a86dba55 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 28 Jul 2011 16:56:33 +0200 Subject: releasing version 0.8.15.5 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3f723f2d6..8797117a7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ -apt (0.8.15.5) UNRELEASED; urgency=low +apt (0.8.15.5) unstable; urgency=low [ David Kalnischkies ] * apt-pkg/deb/deblistparser.cc: - do not assume that the last char on a line is a \n (Closes: #633350) - -- David Kalnischkies Wed, 27 Jul 2011 23:25:45 +0200 + -- Michael Vogt Thu, 28 Jul 2011 16:49:15 +0200 apt (0.8.15.4) unstable; urgency=low -- cgit v1.2.3 From 77de0e831a12aedde05ff6bff8fb07dcbb4074ad Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 1 Aug 2011 12:57:04 +0200 Subject: apt-pkg/pkgcachegen.cc: copy Arch to avoid segfault on cache remap --- apt-pkg/pkgcachegen.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index efd764b51..2bfb77609 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -636,7 +636,9 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress) Dynamic DynV(V); for (; V.end() != true; V++) { - char const * const Arch = P.Arch(); + // copy P.Arch() into a string here as a cache remap + // in NewDepends() later may alter the pointer location + string Arch = P.Arch() == NULL ? "" : P.Arch(); map_ptrloc *OldDepLast = NULL; /* MultiArch handling introduces a lot of implicit Dependencies: - MultiArch: same → Co-Installable if they have the same version -- cgit v1.2.3