alexk / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
3f3ddd
From c771ae28e28b2971869b7801ffc7961f4dcb6544 Mon Sep 17 00:00:00 2001
3f3ddd
From: Panu Matilainen <pmatilai@redhat.com>
3f3ddd
Date: Thu, 10 Jun 2021 10:32:12 +0300
3f3ddd
Subject: [PATCH] Support hash v8 databases from BDB < 4.6 in bdb_ro
3f3ddd
3f3ddd
In Hash v8 databases page type differs from newer ones to denote
3f3ddd
the difference between sorted and unsorted pages.
3f3ddd
3f3ddd
Fixes reading rpm databases from older distros like SLES 11 and RHEL 5
3f3ddd
(RhBug:1965147)
3f3ddd
---
3f3ddd
 lib/backend/bdb_ro.c | 4 ++--
3f3ddd
 1 file changed, 2 insertions(+), 2 deletions(-)
3f3ddd
3f3ddd
diff --git a/lib/backend/bdb_ro.c b/lib/backend/bdb_ro.c
3f3ddd
index 2667ec845..695ef78e3 100644
3f3ddd
--- a/lib/backend/bdb_ro.c
3f3ddd
+++ b/lib/backend/bdb_ro.c
3f3ddd
@@ -276,7 +276,7 @@ static int hash_lookup(struct bdb_cur *cur, const unsigned char *key, unsigned i
3f3ddd
     pg = hash_bucket_to_page(cur->db, bucket);
3f3ddd
     if (bdb_getpage(cur->db, cur->page, pg))
3f3ddd
 	return -1;
3f3ddd
-    if (cur->page[25] != 8 && cur->page[25] != 13)
3f3ddd
+    if (cur->page[25] != 8 && cur->page[25] != 13 && cur->page[25] != 2)
3f3ddd
 	return -1;
3f3ddd
     cur->idx = (unsigned int)-2;
3f3ddd
     cur->numidx = *(uint16_t *)(cur->page + 20);
3f3ddd
@@ -323,7 +323,7 @@ static int hash_next(struct bdb_cur *cur)
3f3ddd
 	    }
3f3ddd
 	    if (bdb_getpage(cur->db, cur->page, pg))
3f3ddd
 		return -1;
3f3ddd
-	    if (cur->page[25] != 8 && cur->page[25] != 13)
3f3ddd
+	    if (cur->page[25] != 8 && cur->page[25] != 13 && cur->page[25] != 2)
3f3ddd
 		return -1;
3f3ddd
 	    cur->numidx = *(uint16_t *)(cur->page + 20);
3f3ddd
 	    continue;
3f3ddd
-- 
3f3ddd
2.33.1
3f3ddd