| author | Jens Alfke <jens@mooseyard.com> | 
| Thu Sep 24 21:46:17 2009 -0700 (2009-09-24) | |
| changeset 5 | 4c10b7956435 | 
| parent 4 | 715d6147ba3a | 
| child 6 | f2cd752db494 | 
1.1 --- a/src/VersionDictionary.cpp Thu Sep 24 10:36:08 2009 -0700 1.2 +++ b/src/VersionDictionary.cpp Thu Sep 24 21:46:17 2009 -0700 1.3 @@ -134,19 +134,24 @@ 1.4 VersionDictionary::Trailer trailer; 1.5 _file->read(trailer); 1.6 _trailerPosition = trailerPos; 1.7 + _previousTrailerPosition = trailer.previousTrailerPosition; 1.8 _count = trailer.count; 1.9 _indexPositions = trailer.indexPositions; 1.10 1.11 if (trailer.magicNumber1 != VersionDictionary::Trailer::kMagicNumber1 1.12 || trailer.magicNumber2 != VersionDictionary::Trailer::kMagicNumber2) 1.13 - throw File::Error(ERANGE, "No trailer found in file (invalid magic numbers)");\ 1.14 - 1.15 + throw File::Error("No trailer found in file (invalid magic numbers)"); 1.16 + if (_previousTrailerPosition >= _trailerPosition) 1.17 + throw File::Error("Bad VersionDictionary trailer (illegal previousTrailerPosition)"); 1.18 1.19 // Map in the file: 1.20 _file->mapRegion(0, _trailerPosition+sizeof(trailer)); 1.21 1.22 // Verify Indexes: 1.23 for (int i=0; i<256; i++) { 1.24 + if (_indexPositions[i] > 0) 1.25 + if (_indexPositions[i] < _previousTrailerPosition || _indexPositions[i] >= _trailerPosition) 1.26 + throw File::Error("Bad VersionDictionary trailer (illegal index position)"); 1.27 const Index *index = _index(i); 1.28 if (index) 1.29 index->validate();