Просмотр исходного кода

* ftparchive/cachedb.cc:
- applied patch from ajt (#379576)

Michael Vogt лет назад: 20
Родитель
Сommit
592b401af9
2 измененных файлов с 9 добавлено и 7 удалено
  1. 3 0
      debian/changelog
  2. 6 7
      ftparchive/cachedb.cc

+ 3 - 0
debian/changelog

@@ -2,6 +2,9 @@ apt (0.6.45) unstable; urgency=low
 
   * apt-pkg/contrib/sha256.cc:
     - fixed the sha256 generation (closes: #378183)
+  * ftparchive/cachedb.cc:
+    - applied patch from ajt to fix Clean() function
+      (closes: #379576)
 
  --
 

+ 6 - 7
ftparchive/cachedb.cc

@@ -453,15 +453,14 @@ bool CacheDB::Clean()
    memset(&Data,0,sizeof(Data));
    while ((errno = Cursor->c_get(Cursor,&Key,&Data,DB_NEXT)) == 0)
    {
-      const char *Colon = (char *)Key.data;
-      for (; Colon != (char *)Key.data+Key.size && *Colon != ':'; Colon++);
-      if ((char *)Key.data+Key.size - Colon > 2)
+      const char *Colon = (char*)memrchr(Key.data, ':', Key.size);
+      if (Colon)
       {
-	 if (stringcmp((char *)Key.data,Colon,"st") == 0 ||
-	     stringcmp((char *)Key.data,Colon,"cn") == 0 ||
-	     stringcmp((char *)Key.data,Colon,"cl") == 0)
+         if (stringcmp(Colon + 1, (char *)Key.data+Key.size,"st") == 0 ||
+             stringcmp(Colon + 1, (char *)Key.data+Key.size,"cl") == 0 ||
+             stringcmp(Colon + 1, (char *)Key.data+Key.size,"cn") == 0)
 	 {
-	    if (FileExists(string(Colon+1,(const char *)Key.data+Key.size)) == true)
+            if (FileExists(string((const char *)Key.data,Colon)) == true)
 		continue;	     
 	 }
       }