Blame SOURCES/gdbm-1.18-backward-compatibility.patch

4509d4
Upstream backport: 00ba17479ff31c6825f0e6f28b965f11525e83f6
4509d4
Fix problem with loading old format of databases exports
4509d4
4509d4
diff -ur gdbm-1.18/src/gdbmopen.c gdbm-patch/src/gdbmopen.c
4509d4
--- gdbm-1.18/src/gdbmopen.c	2018-08-03 10:46:39.000000000 +0200
4509d4
+++ gdbm-patch/src/gdbmopen.c	2022-07-01 08:56:08.000000000 +0200
4509d4
@@ -168,9 +168,14 @@
4509d4
       return GDBM_BLOCK_SIZE_ERROR;
4509d4
     }
4509d4
 
4509d4
-  if (hdr->next_block != st->st_size)
4509d4
-    /* FIXME: Should return GDBM_NEED_RECOVERY instead? */
4509d4
-    return GDBM_BAD_HEADER;
4509d4
+  /* Technically speaking, the condition below should read
4509d4
+         hdr->next_block != st->st_size
4509d4
+     However, gdbm versions prior to commit 4e819c98 could leave
4509d4
+     hdr->next_block pointing beyond current end of file. To ensure
4509d4
+     backward compatibility with these versions, the condition has been
4509d4
+     slackened to this: */
4509d4
+  if (hdr->next_block < st->st_size)
4509d4
+     return GDBM_BAD_HEADER;
4509d4
 
4509d4
   /* Make sure dir and dir + dir_size fall within the file boundary */
4509d4
   if (!(hdr->dir > 0