[packages/man-db] Rel 2; try to fix: mandb: bad fetch on multi key mtools 5 mandb: index cache /var/cache/man/500791 c
arekm
arekm at pld-linux.org
Sat Jul 4 12:41:37 CEST 2026
commit 548f2a4120e620137223f3b9c47aeb399446797d
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sat Jul 4 12:40:51 2026 +0200
Rel 2; try to fix:
mandb: bad fetch on multi key mtools 5
mandb: index cache /var/cache/man/500791 corrupt
man-db-multikey.patch | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++
man-db.spec | 6 ++-
2 files changed, 114 insertions(+), 1 deletion(-)
---
diff --git a/man-db.spec b/man-db.spec
index 61484c8..3aac2f0 100644
--- a/man-db.spec
+++ b/man-db.spec
@@ -7,7 +7,7 @@ Summary: Tools for searching and reading man pages
Summary(pl.UTF-8): Narzędzia do przeszukiwania i czytania stron podręcznika man
Name: man-db
Version: 2.13.1
-Release: 1
+Release: 2
# project man-db GPLv2+
# Gnulib part GPLv3+
License: GPL v2+ and GPL v3+
@@ -20,6 +20,9 @@ Source2: %{name}.sysconfig
Patch0: sgr.patch
# recent nroff uses times()
Patch1: %{name}-sandbox.patch
+# https://gitlab.com/man-db/man-db/-/issues/33 - same name in two sections with
+# differing compression drops a multi key content entry, corrupting the index
+Patch2: %{name}-multikey.patch
URL: https://man-db.gitlab.io/man-db/
BuildRequires: gdbm-devel
BuildRequires: gettext-tools >= 0.18.3
@@ -71,6 +74,7 @@ man (nazywanych man-pages): man, whatis, apropos, manpath i lexgrog:
%setup -q
%patch -P0 -p1
%patch -P1 -p1
+%patch -P2 -p1
%build
%configure \
diff --git a/man-db-multikey.patch b/man-db-multikey.patch
new file mode 100644
index 0000000..f33b71e
--- /dev/null
+++ b/man-db-multikey.patch
@@ -0,0 +1,109 @@
+--- a/libdb/db_store.c
++++ b/libdb/db_store.c
+@@ -410,7 +410,24 @@
+ newkey = make_multi_key (base, in->ext);
+ newcont = make_content (in);
+
+- ret = replace_if_necessary (dbf, in, old, newkey, newcont);
++ /* Store the new multi key directly: it is a distinct page and
++ * normally absent. replace_if_necessary expects a matching name
++ * and extension, so weighing against `old` (a different section)
++ * can hit REPLACE_FAIL on e.g. differing compression and drop
++ * the content while the simple key below still references it,
++ * corrupting the index. Only weigh the page against the multi
++ * key's own content when that key already exists. */
++ if (MYDBM_INSERT (dbf, newkey, newcont)) {
++ datum cont;
++ struct mandata *info;
++
++ cont = MYDBM_FETCH (dbf, newkey);
++ info = split_content (dbf, MYDBM_DPTR (cont));
++ ret = replace_if_necessary (dbf, in, info, newkey,
++ newcont);
++ MYDBM_FREE_DPTR (cont);
++ free_mandata_struct (info);
++ }
+
+ MYDBM_FREE_DPTR (newkey);
+ MYDBM_FREE_DPTR (newcont);
+--- a/src/tests/mandb-multi-key-differing-compression
++++ b/src/tests/mandb-multi-key-differing-compression
+@@ -0,0 +1,44 @@
++#! /bin/sh
++
++# Test for:
++# https://gitlab.com/man-db/man-db/-/issues/33
++#
++# A page name that exists in two sections with differing compression and an
++# equal mtime used to lose one multi key content entry: dbstore weighed the
++# new multi key against the other section's page rather than its own key, hit
++# the "differing compression" REPLACE_FAIL case and dropped the content while
++# the simple key still referenced it. Lookups then failed with "bad fetch on
++# multi key" and declared the index corrupt.
++
++: "${srcdir=.}"
++# shellcheck source-path=SCRIPTDIR
++. "$srcdir/testlib.sh"
++
++: "${MANDB=mandb}"
++: "${ACCESSDB=accessdb}"
++
++init
++fake_config /usr/share/man
++MANPATH="$tmpdir/usr/share/man"
++export MANPATH
++db_ext="$(db_ext)"
++
++write_page foo 1 "$tmpdir/usr/share/man/man1/foo.1.gz" UTF-8 gz '' \
++ 'foo \- section one'
++write_page foo 5 "$tmpdir/usr/share/man/man5/foo.5" UTF-8 '' '' \
++ 'foo \- section five'
++# The trigger is an identical mtime combined with differing compression.
++touch -d '2000-01-01 00:00:00' \
++ "$tmpdir/usr/share/man/man1/foo.1.gz" \
++ "$tmpdir/usr/share/man/man5/foo.5"
++run $MANDB -C "$tmpdir/manpath.config" -u -q "$tmpdir/usr/share/man"
++cat >"$tmpdir/1.exp" <<EOF
++foo -> " foo 1 foo 5"
++foo~1 -> "- 1 1 MTIME A - - gz section one"
++foo~5 -> "- 5 5 MTIME A - - - section five"
++EOF
++accessdb_filter "$tmpdir/usr/share/man/index$db_ext" >"$tmpdir/1.out"
++expect_files_equal 'multi key content kept despite differing compression' \
++ "$tmpdir/1.exp" "$tmpdir/1.out"
++
++finish
+--- a/src/tests/Makefile.am
++++ b/src/tests/Makefile.am
+@@ -53,6 +53,7 @@
+ mandb-bogus-symlink \
+ mandb-cachedir-tag \
+ mandb-empty-page \
++ mandb-multi-key-differing-compression \
+ mandb-purge-updates-timestamp \
+ mandb-regular-file-symlink-changes \
+ mandb-symlink-beats-whatis-ref \
+--- a/src/tests/Makefile.in
++++ b/src/tests/Makefile.in
+@@ -2288,6 +2288,7 @@
+ mandb-bogus-symlink \
+ mandb-cachedir-tag \
+ mandb-empty-page \
++ mandb-multi-key-differing-compression \
+ mandb-purge-updates-timestamp \
+ mandb-regular-file-symlink-changes \
+ mandb-symlink-beats-whatis-ref \
+@@ -2786,6 +2787,13 @@
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
++ "$$tst" $(AM_TESTS_FD_REDIRECT)
++mandb-multi-key-differing-compression.log: mandb-multi-key-differing-compression
++ @p='mandb-multi-key-differing-compression'; \
++ b='mandb-multi-key-differing-compression'; \
++ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
++ --log-file $$b.log --trs-file $$b.trs \
++ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+ mandb-purge-updates-timestamp.log: mandb-purge-updates-timestamp
+ @p='mandb-purge-updates-timestamp'; \
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/man-db.git/commitdiff/548f2a4120e620137223f3b9c47aeb399446797d
More information about the pld-cvs-commit
mailing list