Fix segfault when trying to use unknown database backend

This commit is contained in:
Panu Matilainen 2020-05-12 12:56:04 +03:00
parent d451552090
commit 422abdab32
2 changed files with 34 additions and 1 deletions

View File

@ -0,0 +1,29 @@
From 853c48ba6468ce1a516621a2fa6d1fc51e4f7410 Mon Sep 17 00:00:00 2001
Message-Id: <853c48ba6468ce1a516621a2fa6d1fc51e4f7410.1589277227.git.pmatilai@redhat.com>
From: Panu Matilainen <pmatilai@redhat.com>
Date: Thu, 2 Apr 2020 09:14:36 +0300
Subject: [PATCH] Fix regression causing segfault on database autodetection
If configuration points to non-existent backend, tryBackend() will
segfault on the first call. Duh. Regression introduced in commit
3eb0eed3806b41efdf86f0433d0b5d7d6c953561.
---
lib/backend/dbi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/backend/dbi.c b/lib/backend/dbi.c
index b51fc7ba3..94823b14c 100644
--- a/lib/backend/dbi.c
+++ b/lib/backend/dbi.c
@@ -52,7 +52,7 @@ dbiIndex dbiNew(rpmdb rdb, rpmDbiTagVal rpmtag)
static int tryBackend(const char *dbhome, const struct rpmdbOps_s *be)
{
int rc = 0;
- if (be->path) {
+ if (be && be->path) {
char *path = rstrscat(NULL, dbhome, "/", be->path, NULL);
rc = (access(path, F_OK) == 0);
free(path);
--
2.26.2

View File

@ -25,7 +25,7 @@
%global rpmver 4.15.90 %global rpmver 4.15.90
%global snapver git14971 %global snapver git14971
%global rel 11 %global rel 12
%global srcver %{rpmver}%{?snapver:-%{snapver}} %global srcver %{rpmver}%{?snapver:-%{snapver}}
%global srcdir %{?snapver:testing}%{!?snapver:rpm-%(echo %{rpmver} | cut -d'.' -f1-2).x} %global srcdir %{?snapver:testing}%{!?snapver:rpm-%(echo %{rpmver} | cut -d'.' -f1-2).x}
@ -64,6 +64,7 @@ Patch101: 0001-rpmfc-Do-not-prepend-buildroot-to-a-path-for-paramet.patch
Patch102: 0001-Fix-regression-causing-all-ELF-files-classified-as-O.patch Patch102: 0001-Fix-regression-causing-all-ELF-files-classified-as-O.patch
Patch103: 0001-Warn-on-undefined-components-in-buildtree-macros.patch Patch103: 0001-Warn-on-undefined-components-in-buildtree-macros.patch
Patch104: 0001-Don-t-look-into-source-package-provides-in-depsolvin.patch Patch104: 0001-Don-t-look-into-source-package-provides-in-depsolvin.patch
Patch105: 0001-Fix-regression-causing-segfault-on-database-autodete.patch
# These are not yet upstream # These are not yet upstream
Patch906: rpm-4.7.1-geode-i686.patch Patch906: rpm-4.7.1-geode-i686.patch
@ -551,6 +552,9 @@ fi
%doc doc/librpm/html/* %doc doc/librpm/html/*
%changelog %changelog
* Tue May 12 2020 Panu Matilainen <pmatilai@redhat.com> - 4.15.90-0.git14971.12
- Fix segfault when trying to use unknown database backend
* Thu May 7 2020 Panu Matilainen <pmatilai@redhat.com> - 4.15.90-0.git14971.11 * Thu May 7 2020 Panu Matilainen <pmatilai@redhat.com> - 4.15.90-0.git14971.11
- Flag BDB databases for rebuild on next reboot whenever rpm is updated - Flag BDB databases for rebuild on next reboot whenever rpm is updated
- Switch default database to sqlite (#1818910) - Switch default database to sqlite (#1818910)