Bug#647590: "apt-cache show" does not handle Description field
retitle 647590 "apt-cache show" does not handle missing Description field
thanks
Hi,
the code for apt-cache show assumes there always is a Description:
field and breaks if this is not true. It also does not work correctly
should any previous field contain "Description:".
Attached is a patch that prevents apt-cache from crashing if the
Description field is missing (I don't like it too much though); it might
still make problems if Buffer is not null-terminated (I did not check).
A proper fix also needs to macke sure the "Description:" is found at the
beginning of a line.
Regards,
Ansgar
diff -Nru apt-0.8.10.3+squeeze1/cmdline/apt-cache.cc apt-0.8.10.3+squeeze2/cmdline/apt-cache.cc
--- apt-0.8.10.3+squeeze1/cmdline/apt-cache.cc 2011-04-15 09:30:33.000000000 +0200
+++ apt-0.8.10.3+squeeze2/cmdline/apt-cache.cc 2011-11-11 12:19:06.000000000 +0100
@@ -1209,6 +1209,9 @@
// Get a pointer to start of Description field
const unsigned char *DescP = (unsigned char*)strstr((char*)Buffer, "Description:");
+ if (!DescP || DescP > &Buffer[V.FileList()->Size]) {
+ DescP = &Buffer[V.FileList()->Size];
+ }
// Write all but Description
if (fwrite(Buffer,1,DescP - Buffer,stdout) < (size_t)(DescP - Buffer))
@@ -1224,7 +1227,7 @@
cout << "Description" << ( (strcmp(Desc.LanguageCode(),"") != 0) ? "-" : "" ) << Desc.LanguageCode() << ": " << P.LongDesc();
// Find the first field after the description (if there is any)
- for(DescP++;DescP != &Buffer[V.FileList()->Size];DescP++)
+ for(;DescP != &Buffer[V.FileList()->Size];DescP++)
{
if(*DescP == '\n' && *(DescP+1) != ' ')
{
Reply to: