[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#376777: parsing packages files: Reads from pipe results in corrupt data



The problem lies in the addition of several lines in
apt/apt-pkg/tagfile.cc that were added for the mmappable package file
case, but in the fix for #376777, were not put inside proper
ifstatements for the non-mmap case, and are actually broken in that
case (corruption every 64kB of package file).

This patch reverts to having really the pre-mmap code in cases where
mmap is not possible, as a more complete fix than the fix for #376777
(which I believe is incomplete and still results in broken behaviour,
though more subtly).

Well, patch, pseudo-code -- Map isn't in scope in Scan, so this code
doesn't compile. And passing it as parameter changes the API (why Scan
is in the API is unclear to me). Someone better aware of the logic
involved here should really take a look -- maybe those two changes in
Scan can actually really be reverted without bad effects.

--- apt-pkg/tagfile.cc	2006-07-27 00:51:47.000000000 +0200
+++ apt-pkg/tagfile.cc	2006-08-19 00:54:32.240562270 +0200
@@ -207,7 +207,7 @@
    Stop = Section = Start;
    memset(AlphaIndexes,0,sizeof(AlphaIndexes));
 
-   if (Stop == 0 || MaxLength == 0)
+   if (Stop == 0 || (Map != NULL && MaxLength == 0))
       return false;
    
    TagCount = 0;
@@ -238,7 +238,7 @@
       Stop++;
    }
 
-   if ((Stop+1 >= End) && (End[-1] == '\n' || End[-1] == '\r'))
+   if (Map != NULL && (Stop+1 >= End) && (End[-1] == '\n' || End[-1] == '\r'))
    {
       Indexes[TagCount] = (End - 1) - Section;
       return true;

Thanks,
--Jeroen

-- 
Jeroen van Wolffelaar
Jeroen@wolffelaar.nl (also for Jabber & MSN; ICQ: 33944357)
http://Jeroen.A-Eskwadraat.nl



Reply to: