Skip to content

Commit

Permalink
Support hash v8 databases from BDB < 4.6 in bdb_ro
Browse files Browse the repository at this point in the history
In Hash v8 databases page type differs from newer ones to denote
the difference between sorted and unsorted pages.

Fixes reading rpm databases from older distros like SLES 11 and RHEL 5
(RhBug:1965147)
  • Loading branch information
pmatilai committed Jun 10, 2021
1 parent 992a4f9 commit b00994f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/backend/bdb_ro.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ static int hash_lookup(struct bdb_cur *cur, const unsigned char *key, unsigned i
pg = hash_bucket_to_page(cur->db, bucket);
if (bdb_getpage(cur->db, cur->page, pg))
return -1;
if (cur->page[25] != 8 && cur->page[25] != 13)
if (cur->page[25] != 8 && cur->page[25] != 13 && cur->page[25] != 2)
return -1;
cur->idx = (unsigned int)-2;
cur->numidx = *(uint16_t *)(cur->page + 20);
Expand Down Expand Up @@ -323,7 +323,7 @@ static int hash_next(struct bdb_cur *cur)
}
if (bdb_getpage(cur->db, cur->page, pg))
return -1;
if (cur->page[25] != 8 && cur->page[25] != 13)
if (cur->page[25] != 8 && cur->page[25] != 13 && cur->page[25] != 2)
return -1;
cur->numidx = *(uint16_t *)(cur->page + 20);
continue;
Expand Down

0 comments on commit b00994f

Please sign in to comment.