michal-grzedzicki / rpms / rpm

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