]> git.saurik.com Git - apt.git/commitdiff
fix problematic use of tolower() when calculating the version
authorMichael Vogt <michael.vogt@ubuntu.com>
Thu, 23 Apr 2009 10:53:48 +0000 (12:53 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Thu, 23 Apr 2009 10:53:48 +0000 (12:53 +0200)
hash by using locale independant tolower_ascii() function.
Thanks to M. Vefa Bicakci (LP: #80248)

apt-pkg/contrib/strutl.cc
apt-pkg/contrib/strutl.h
apt-pkg/deb/deblistparser.cc
apt-pkg/pkgcache.cc
debian/changelog

index 327381d035fcd7625ca24166ee15f654f0dc4489..0b1bc3c98d6667fa54f437a85589bf31a3a9d918 100644 (file)
@@ -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
index d9972abf43a3035c55cff20ffebd992a5fc5c025..51416a24abc40c618b4fcca3420c74419e2adb4b 100644 (file)
@@ -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));}; \
index 896d4d6d8590c3ef697d3171ea5f0bf994593e5c..55ba1f8c4baf9ad3a92aa74ab4fe078cd4575f98 100644 (file)
@@ -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] != '=')
index 4fbf42c4bb6c4f82dd919ad8fbe2647eb58df06d..6687864ee888b4af5bd7f5195951b7b88e996f11 100644 (file)
@@ -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);
 }
 
index 75a3e2c0a47f4889d12fa171e06c67109fec5ace..45804bc638ab858489d8ee9317ee65bc8265f590 100644 (file)
@@ -48,6 +48,10 @@ apt (0.7.21) UNRELEASED; urgency=low
     - add Acquire::https::AllowRedirect support
   * methods/gpgv.cc:
     - properly check for expired and revoked keys (closes: #433091)
+  * fix problematic use of tolower() when calculating the version 
+    hash by using locale independant tolower_ascii() function. 
+    Thanks to M. Vefa Bicakci (LP: #80248)
+    
 
   [ Dereck Wonnacott ]
   * apt-ftparchive might write corrupt Release files (LP: #46439)