]> git.saurik.com Git - apt.git/commitdiff
merged from debian-apt
authorMichael Vogt <michael.vogt@ubuntu.com>
Thu, 28 Jul 2011 07:29:44 +0000 (09:29 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Thu, 28 Jul 2011 07:29:44 +0000 (09:29 +0200)
apt-pkg/deb/deblistparser.cc
debian/changelog
test/integration/test-bug-633350-do-not-kill-last-char-in-Release [new file with mode: 0755]

index d23207f4ae85839421f67d6d72b32b8a19082362..59c4ee365615f4a04dde3061c160fd1f02c0a3b2 100644 (file)
@@ -779,7 +779,9 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
       size_t len = 0;
 
       // Skip empty lines
-      for (; buffer[len] == '\r' && buffer[len] == '\n'; ++len);
+      for (; buffer[len] == '\r' && buffer[len] == '\n'; ++len)
+         /* nothing */
+         ;
       if (buffer[len] == '\0')
         continue;
 
@@ -793,13 +795,25 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
       }
 
       // seperate the tag from the data
-      for (; buffer[len] != ':' && buffer[len] != '\0'; ++len);
+      for (; buffer[len] != ':' && buffer[len] != '\0'; ++len)
+         /* nothing */
+         ;
       if (buffer[len] == '\0')
         continue;
       char* dataStart = buffer + len;
-      for (++dataStart; *dataStart == ' '; ++dataStart);
+      for (++dataStart; *dataStart == ' '; ++dataStart)
+         /* nothing */
+         ;
       char* dataEnd = dataStart;
-      for (++dataEnd; *dataEnd != '\0'; ++dataEnd);
+      for (++dataEnd; *dataEnd != '\0'; ++dataEnd)
+         /* nothing */
+         ;
+      // The last char should be a newline, but we can never be sure: #633350
+      char* lineEnd = dataEnd;
+      for (--lineEnd; *lineEnd == '\r' || *lineEnd == '\n'; --lineEnd)
+         /* nothing */
+         ;
+      ++lineEnd;
 
       // which datastorage need to be updated
       map_ptrloc* writeTo = NULL;
@@ -814,7 +828,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
index ed9492dd6155dfcb10bcfb7a1d9458818c618f55..4d9a7473b6ed64645d3bab3223ef1b516b3245b4 100644 (file)
@@ -77,6 +77,14 @@ apt (0.8.16~exp1) experimental; urgency=low
 
  -- Michael Vogt <mvo@debian.org>  Wed, 29 Jun 2011 12:40:31 +0200
 
+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 <kalnischkies@gmail.com>  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 (executable)
index 0000000..3d38355
--- /dev/null
@@ -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