diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-10-18 20:33:10 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-10-18 20:33:10 +0300 |
commit | 00ba17479ff31c6825f0e6f28b965f11525e83f6 (patch) | |
tree | fea289bb407672a6c03f73e7ba1157a0d32ae86d | |
parent | 852ff1b6e81ce13fdcd1fd4fb272b17d760760b3 (diff) | |
download | gdbm-00ba17479ff31c6825f0e6f28b965f11525e83f6.tar.gz gdbm-00ba17479ff31c6825f0e6f28b965f11525e83f6.tar.bz2 |
Restore backward compatibility with older databases
* src/gdbmopen.c (validate_header): Silently accept databases with next_block
pointing beyond end of file.
-rw-r--r-- | src/gdbmopen.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gdbmopen.c b/src/gdbmopen.c index fe2527e..42f429d 100644 --- a/src/gdbmopen.c +++ b/src/gdbmopen.c | |||
@@ -166,13 +166,19 @@ validate_header (gdbm_file_header const *hdr, struct stat const *st) | |||
166 | && hdr->block_size - sizeof (gdbm_file_header) >= | 166 | && hdr->block_size - sizeof (gdbm_file_header) >= |
167 | sizeof(hdr->avail.av_table[0]))) | 167 | sizeof(hdr->avail.av_table[0]))) |
168 | { | 168 | { |
169 | return GDBM_BLOCK_SIZE_ERROR; | 169 | return GDBM_BLOCK_SIZE_ERROR; |
170 | } | 170 | } |
171 | 171 | ||
172 | if (hdr->next_block != st->st_size) | 172 | /* Technically speaking, the condition below should read |
173 | hdr->next_block != st->st_size | ||
174 | However, gdbm versions prior to commit 4e819c98 could leave | ||
175 | hdr->next_block pointing beyond current end of file. To ensure | ||
176 | backward compatibility with these versions, the condition has been | ||
177 | slackened to this: */ | ||
178 | if (hdr->next_block < st->st_size) | ||
173 | result = GDBM_NEED_RECOVERY; | 179 | result = GDBM_NEED_RECOVERY; |
174 | 180 | ||
175 | /* Make sure dir and dir + dir_size fall within the file boundary */ | 181 | /* Make sure dir and dir + dir_size fall within the file boundary */ |
176 | if (!(hdr->dir > 0 | 182 | if (!(hdr->dir > 0 |
177 | && hdr->dir < st->st_size | 183 | && hdr->dir < st->st_size |
178 | && hdr->dir_size > 0 | 184 | && hdr->dir_size > 0 |