From efe0ebcbc14e43042083ce76043c69b8eb829280 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 22 Apr 2010 13:48:58 +0300 Subject: [PATCH] Protect rpmtsVerifyDB() with transaction lock - BDB docs state that db->verify() doesn't perform any locking even when used within an environment, and should only be used on files that are not being modified by another thread of control. Grabbing the transaction lock while verifying mostly ensures nobodys writing to the db behind our back. --- lib/rpmts.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rpmts.c b/lib/rpmts.c index 3beb1a4..0dc39d9 100644 --- a/lib/rpmts.c +++ b/lib/rpmts.c @@ -135,7 +135,13 @@ int rpmtsRebuildDB(rpmts ts) int rpmtsVerifyDB(rpmts ts) { - return rpmdbVerify(ts->rootDir); + int rc = -1; + rpmlock lock = rpmtsAcquireLock(ts); + if (lock) { + int rc = rpmdbVerify(ts->rootDir); + rpmlockFree(lock); + } + return rc; } /* keyp might no be defined. */ -- 2.7.4