Bug#379576: apt-utils: apt-ftparchive clean doesn't work due to cachedb format change
Package: apt-utils
Version: 0.6.44.2
Severity: important
Tags: patch
The Clean() function in ftparchive/cachedb.cc wasn't changed to match the
new format of the cachedb databases in 0.6.44. It's cleaning everything
but records matching "<type>:<filename>" where <type> is one of "st",
"cn" or "cl", and <filename> is an existing file; but all the records
are now "<filename>:<type>" instead.
The following patch compiles, but is untested atm:
--- cachedb.cc.old 2006-07-24 21:10:24.000000000 +1000
+++ cachedb.cc 2006-07-24 21:34:01.000000000 +1000
@@ -453,15 +453,14 @@
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;
}
}
Cheers,
aj
Reply to: