# HG changeset patch # User Jens Alfke # Date 1253853977 25200 # Node ID 4c10b7956435d6106ee1facc9d77865729fd29fe # Parent 715d6147ba3aac80bb4ba4a8ad34013c83b15327 Oops, forgot to set _previousTrailerPosition, which made the previousVersion() accessor not work. Fixed. Also added some sanity-checking of its value. diff -r 715d6147ba3a -r 4c10b7956435 src/VersionDictionary.cpp --- a/src/VersionDictionary.cpp Thu Sep 24 10:36:08 2009 -0700 +++ b/src/VersionDictionary.cpp Thu Sep 24 21:46:17 2009 -0700 @@ -134,19 +134,24 @@ VersionDictionary::Trailer trailer; _file->read(trailer); _trailerPosition = trailerPos; + _previousTrailerPosition = trailer.previousTrailerPosition; _count = trailer.count; _indexPositions = trailer.indexPositions; if (trailer.magicNumber1 != VersionDictionary::Trailer::kMagicNumber1 || trailer.magicNumber2 != VersionDictionary::Trailer::kMagicNumber2) - throw File::Error(ERANGE, "No trailer found in file (invalid magic numbers)");\ - + throw File::Error("No trailer found in file (invalid magic numbers)"); + if (_previousTrailerPosition >= _trailerPosition) + throw File::Error("Bad VersionDictionary trailer (illegal previousTrailerPosition)"); // Map in the file: _file->mapRegion(0, _trailerPosition+sizeof(trailer)); // Verify Indexes: for (int i=0; i<256; i++) { + if (_indexPositions[i] > 0) + if (_indexPositions[i] < _previousTrailerPosition || _indexPositions[i] >= _trailerPosition) + throw File::Error("Bad VersionDictionary trailer (illegal index position)"); const Index *index = _index(i); if (index) index->validate();