From 76dbdfc7f02096758f63bcb6d306b54d5a2d0d02 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 24 Apr 2009 19:53:19 +0200 Subject: * fix problematic use of tolower() when calculating the version hash by using locale independant tolower_ascii() function. Thanks to M. Vefa Bicakci (LP: #80248) * build fixes for g++-4.4 * include dmesg output in apport package failures --- apt-pkg/acquire.cc | 3 ++- apt-pkg/contrib/sha256.h | 1 + apt-pkg/contrib/strutl.cc | 11 +++++++++++ apt-pkg/contrib/strutl.h | 1 + apt-pkg/deb/deblistparser.cc | 2 +- apt-pkg/deb/dpkgpm.cc | 17 +++++++++++++++++ apt-pkg/pkgcache.cc | 4 ++-- 7 files changed, 35 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 38944bbac..2e6bd3401 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -24,7 +24,8 @@ #include #include - +#include + #include #include #include diff --git a/apt-pkg/contrib/sha256.h b/apt-pkg/contrib/sha256.h index 1951f053b..5934b5641 100644 --- a/apt-pkg/contrib/sha256.h +++ b/apt-pkg/contrib/sha256.h @@ -17,6 +17,7 @@ #include #include #include +#include using std::string; using std::min; diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index fe9082f63..3b7a67db0 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1074,6 +1074,17 @@ char *safe_snprintf(char *Buffer,char *End,const char *Format,...) } /*}}}*/ +// tolower_ascii - tolower() function that ignores the locale /*{{{*/ +// --------------------------------------------------------------------- +/* */ +int tolower_ascii(int c) +{ + if (c >= 'A' and c <= 'Z') + return c + 32; + return c; +} + /*}}}*/ + // CheckDomainList - See if Host is in a , seperate list /*{{{*/ // --------------------------------------------------------------------- /* The domain list is a comma seperate list of domains that are suffix diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index d9972abf4..51416a24a 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -62,6 +62,7 @@ void ioprintf(ostream &out,const char *format,...) APT_FORMAT2; void strprintf(string &out,const char *format,...) APT_FORMAT2; char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_FORMAT3; bool CheckDomainList(const string &Host, const string &List); +int tolower_ascii(int c); #define APT_MKSTRCMP(name,func) \ inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \ diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 896d4d6d8..55ba1f8c4 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -213,7 +213,7 @@ unsigned short debListParser::VersionHash() for (; Start != End; Start++) { if (isspace(*Start) == 0) - *I++ = tolower(*Start); + *I++ = tolower_ascii(*Start); if (*Start == '<' && Start[1] != '<' && Start[1] != '=') *I++ = '='; if (*Start == '>' && Start[1] != '>' && Start[1] != '=') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index d8c38427f..f57bff32c 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1123,6 +1123,23 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) fclose(log); } } + + // attach dmesg log (to learn about segfaults) + if (FileExists("/bin/dmesg")) + { + FILE *log = NULL; + char buf[1024]; + + fprintf(report, "Dmesg:\n"); + log = popen("/bin/dmesg","r"); + if(log != NULL) + { + while( fgets(buf, sizeof(buf), log) != NULL) + fprintf(report, " %s", buf); + fclose(log); + } + } fclose(report); + } /*}}}*/ diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 4fbf42c4b..6687864ee 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -163,7 +163,7 @@ unsigned long pkgCache::sHash(const string &Str) const { unsigned long Hash = 0; for (string::const_iterator I = Str.begin(); I != Str.end(); I++) - Hash = 5*Hash + tolower(*I); + Hash = 5*Hash + tolower_ascii(*I); return Hash % _count(HeaderP->HashTable); } @@ -171,7 +171,7 @@ unsigned long pkgCache::sHash(const char *Str) const { unsigned long Hash = 0; for (const char *I = Str; *I != 0; I++) - Hash = 5*Hash + tolower(*I); + Hash = 5*Hash + tolower_ascii(*I); return Hash % _count(HeaderP->HashTable); } -- cgit v1.2.3