diff -r 851de24ecb61 -r 4c10b7956435 src/VersionDictionary.cpp --- a/src/VersionDictionary.cpp Sun Sep 20 21:25:47 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();