Author: hdu
Date: Mon Mar 26 16:07:38 2012
New Revision: 1305420

URL: http://svn.apache.org/viewvc?rev=1305420&view=rev
Log:
#i119113# fix of-by-one when importing BDB files

Modified:
    incubator/ooo/trunk/main/desktop/source/deployment/dp_persmap.cxx

Modified: incubator/ooo/trunk/main/desktop/source/deployment/dp_persmap.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/desktop/source/deployment/dp_persmap.cxx?rev=1305420&r1=1305419&r2=1305420&view=diff
==============================================================================
--- incubator/ooo/trunk/main/desktop/source/deployment/dp_persmap.cxx (original)
+++ incubator/ooo/trunk/main/desktop/source/deployment/dp_persmap.cxx Mon Mar 
26 16:07:38 2012
@@ -399,7 +399,9 @@ bool PersistentMap::importFromBDB()
                // parse the next _db_page
                const sal_uInt8* const pPage = &aRawBDB[ nPgNo * nPgSize];
                const sal_uInt8* const pEnd = pPage + nPgSize;
-               const int nHfOffset = bLE ? (pPage[22] + (pPage[23]<<8)) : 
(pPage[23] + (pPage[22]<<8)); 
+               const int nHfOffset = bLE ? (pPage[22] + (pPage[23]<<8)) : 
(pPage[23] + (pPage[22]<<8));
+               if( nHfOffset <= 0)
+                       continue;
                const sal_uInt8* pCur = pPage + nHfOffset;
                // iterate through the entries
                for(; pCur < pEnd; ++pCur) {
@@ -423,6 +425,7 @@ bool PersistentMap::importFromBDB()
                        if( (pCur < pEnd) && (*pCur > 0x01))
                                continue;
                        const OString aKey( (sal_Char*)pKey, pCur - pKey);
+                       --pCur; // prepare for next round by rewinding to end 
of key-string
                        
                        // add the key/value pair
                        add( aKey, aVal);


Reply via email to