Michael Vogt лет назад: 14
Родитель
Сommit
3f81d67e1b

+ 2 - 2
apt-pkg/cachefilter.cc

@@ -10,11 +10,11 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/pkgcache.h>
 
-#include <apti18n.h>
-
 #include <string>
 
 #include <regex.h>
+
+#include <apti18n.h>
 									/*}}}*/
 namespace APT {
 namespace CacheFilter {

+ 12 - 5
apt-pkg/deb/deblistparser.cc

@@ -215,15 +215,22 @@ string debListParser::DescriptionLanguage()
  */
 MD5SumValue debListParser::Description_md5()
 {
-   string value = Section.FindS("Description-md5");
-
-   if (value.empty()) 
+   string const value = Section.FindS("Description-md5");
+   if (value.empty() == true)
    {
       MD5Summation md5;
       md5.Add((Description() + "\n").c_str());
       return md5.Result();
-   } else
-      return MD5SumValue(value);
+   }
+   else if (likely(value.size() == 32))
+   {
+      if (likely(value.find_first_not_of("0123456789abcdefABCDEF") == string::npos))
+	 return MD5SumValue(value);
+      _error->Error("Malformed Description-md5 line; includes invalid character '%s'", value.c_str());
+      return MD5SumValue();
+   }
+   _error->Error("Malformed Description-md5 line; doesn't have the required length (32 != %d) '%s'", (int)value.size(), value.c_str());
+   return MD5SumValue();
 }
                                                                         /*}}}*/
 // ListParser::UsePackage - Update a package structure			/*{{{*/

+ 2 - 1
apt-pkg/packagemanager.cc

@@ -25,9 +25,10 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/sptr.h>
 
-#include <apti18n.h>
 #include <iostream>
 #include <fcntl.h>
+
+#include <apti18n.h>
 									/*}}}*/
 using namespace std;
 

+ 8 - 2
apt-pkg/pkgcachegen.cc

@@ -286,7 +286,7 @@ bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator
       pkgCache::DescIterator Desc = Ver.DescriptionList();
 
       // a version can only have one md5 describing it
-      if (MD5SumValue(Desc.md5()) != CurMd5)
+      if (Desc.end() == true || MD5SumValue(Desc.md5()) != CurMd5)
 	 continue;
 
       // don't add a new description if we have one for the given
@@ -304,6 +304,9 @@ bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator
 
       void const * const oldMap = Map.Data();
       map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, *LastDesc);
+      if (unlikely(descindex == 0 && _error->PendingError()))
+	 return _error->Error(_("Error occurred while processing %s (%s%d)"),
+			      Pkg.Name(), "NewDescription", 1);
       if (oldMap != Map.Data())
 	 LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
       *LastDesc = descindex;
@@ -456,6 +459,9 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
 
    oldMap = Map.Data();
    map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, *LastDesc);
+   if (unlikely(descindex == 0 && _error->PendingError()))
+      return _error->Error(_("Error occurred while processing %s (%s%d)"),
+			   Pkg.Name(), "NewDescription", 2);
    if (oldMap != Map.Data())
        LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap;
    *LastDesc = descindex;
@@ -1453,7 +1459,7 @@ bool IsDuplicateDescription(pkgCache::DescIterator Desc,
 			    MD5SumValue const &CurMd5, std::string const &CurLang)
 {
    // Descriptions in the same link-list have all the same md5
-   if (MD5SumValue(Desc.md5()) != CurMd5)
+   if (Desc.end() == true || MD5SumValue(Desc.md5()) != CurMd5)
       return false;
    for (; Desc.end() == false; ++Desc)
       if (Desc.LanguageCode() == CurLang)

+ 4 - 2
cmdline/apt-extracttemplates.cc

@@ -36,11 +36,13 @@
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <locale.h>
+
 #include <fstream>
 
-#include <locale.h>
-#include <apti18n.h>
 #include "apt-extracttemplates.h"
+
+#include <apti18n.h>
 									/*}}}*/
 
 using namespace std;

+ 4 - 3
cmdline/apt-internal-solver.cc

@@ -7,6 +7,8 @@
    ##################################################################### */
 									/*}}}*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/error.h>
 #include <apt-pkg/cmndline.h>
 #include <apt-pkg/init.h>
@@ -18,11 +20,10 @@
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/pkgsystem.h>
 
-#include <config.h>
-#include <apti18n.h>
-
 #include <unistd.h>
 #include <cstdio>
+
+#include <apti18n.h>
 									/*}}}*/
 
 // ShowHelp - Show a help screen					/*{{{*/

+ 11 - 1
debian/changelog

@@ -24,8 +24,18 @@ apt (0.9.3) unstable; urgency=low
   * edsp/edspsystem.cc:
     - check with RealFileExists for scenario file as otherwise a directory
       like one provided with RootDir triggers the usage of EDSP
+  * debian/libapt-inst1.5.symbols:
+    - use the correct library name the symbols header
+  * apt-pkg/pkgcachegen.cc:
+    - check if NewDescription allocation has failed and error out accordingly
+    - check if we work on a valid description in IsDuplicateDescription as
+      we end up working on dangling pointers otherwise which segfaults on
+      s390x and ppc64 (Closes: #669427)
+  * apt-pkg/deb/deblistparser.cc:
+    - check length and containing chars for a given description md5sum
+  * ensure that apti18n.h is included last as advertised (Closes: #671623)
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 23 Apr 2012 22:02:58 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 05 May 2012 15:35:16 +0200
 
 apt (0.9.2) unstable; urgency=low
 

+ 1 - 1
debian/libapt-inst1.5.symbols

@@ -1,4 +1,4 @@
-libapt-inst.so.1.4 libapt-inst1.4 #MINVER#
+libapt-inst.so.1.5 libapt-inst1.5 #MINVER#
 * Build-Depends-Package: libapt-pkg-dev
  (c++)"ExtractTar::Done(bool)@Base" 0.8.0
  (c++)"ExtractTar::Go(pkgDirStream&)@Base" 0.8.0

+ 3 - 2
ftparchive/cachedb.cc

@@ -19,11 +19,12 @@
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/fileutl.h>
-    
+
 #include <netinet/in.h>       // htonl, etc
 
-#include <apti18n.h>
 #include "cachedb.h"
+
+#include <apti18n.h>
 									/*}}}*/
 
 // CacheDB::ReadyDB - Ready the DB2					/*{{{*/

+ 3 - 1
ftparchive/contents.cc

@@ -38,13 +38,15 @@
 #include <apt-pkg/debfile.h>
 #include <apt-pkg/extracttar.h>
 #include <apt-pkg/error.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <malloc.h>
 
-#include <apti18n.h>
 #include "contents.h"
+
+#include <apti18n.h>
 									/*}}}*/
 
 // GenContents::~GenContents - Free allocated memory			/*{{{*/

+ 2 - 1
ftparchive/override.cc

@@ -12,13 +12,14 @@
 // Include Files							/*{{{*/
 #include <config.h>
 
-#include <apti18n.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/error.h>
 
 #include <stdio.h>
 
 #include "override.h"
+
+#include <apti18n.h>
 									/*}}}*/
 
 // Override::ReadOverride - Read the override file			/*{{{*/

+ 17 - 0
prepare-release

@@ -4,6 +4,23 @@ VERSION=$(dpkg-parsechangelog | sed -n -e '/^Version:/s/^Version: //p')
 DISTRIBUTION=$(dpkg-parsechangelog | sed -n -e '/^Distribution:/s/^Distribution: //p')
 
 if [ "$1" = 'pre-export' ]; then
+	libraryversioncheck() {
+		LIBRARY="$1"
+		VERSION="$2"
+		if [ ! -e "debian/${LIBRARY}${VERSION}.symbols" ]; then
+		   echo >&2 "Library ${LIBRARY} in version ${VERSION} has no symbols file! (maybe forgot to rename?)"
+		   exit 1
+		fi
+		if [ "$(head -n1 "debian/${LIBRARY}${VERSION}.symbols")" != "${LIBRARY}.so.${VERSION} ${LIBRARY}${VERSION} #MINVER#" ]; then
+		   echo >&2 "Library ${LIBRARY}${VERSION} has incorrect version in symbol header! (»$(head -n1 "debian/${LIBRARY}${VERSION}.symbols")«)"
+		   exit 2
+		fi
+	}
+
+	libraryversioncheck 'libapt-pkg' "$(awk -v ORS='.' '/^\#define APT_PKG_M/ {print $3}' apt-pkg/init.h | sed 's/\.$//')"
+	libraryversioncheck 'libapt-inst' "$(egrep '^MAJOR=' apt-inst/makefile |cut -d '=' -f 2)"
+
+
 	if [ "$DISTRIBUTION" = 'sid' ]; then
 		echo >&2 '»sid« is not a valid distribution. Replace it with »unstable« for you'
 		sed -i -e 's/) sid; urgency=/) unstable; urgency=/' debian/changelog

+ 22 - 0
test/libapt/hashsums_test.cc

@@ -42,6 +42,28 @@ template <class T> void TestMill(const char *Out)
 
 int main(int argc, char** argv)
 {
+   // test HashSumValue which doesn't calculate but just stores sums
+   {
+   string md5sum = argv[2];
+   MD5SumValue md5(md5sum);
+   equals(md5.Value(), md5sum);
+   }
+   {
+   string sha1sum = argv[3];
+   SHA1SumValue sha1(sha1sum);
+   equals(sha1.Value(), sha1sum);
+   }
+   {
+   string sha2sum = argv[4];
+   SHA256SumValue sha2(sha2sum);
+   equals(sha2.Value(), sha2sum);
+   }
+   {
+   string sha2sum = argv[5];
+   SHA512SumValue sha2(sha2sum);
+   equals(sha2.Value(), sha2sum);
+   }
+
    // From  FIPS PUB 180-1
    Test<SHA1Summation>("","da39a3ee5e6b4b0d3255bfef95601890afd80709");
    Test<SHA1Summation>("abc","a9993e364706816aba3e25717850c26c9cd0d89d");