From be64821b908fdb1ff3c12530430d1cf046839e60 Mon Sep 17 00:00:00 2001
From: licunlong <licunlong1@huawei.com>
Date: Thu, 20 Jan 2022 19:59:44 +0800
Subject: [PATCH] treat 0 as valid file descriptor The descriptor is openned in
 rpmpkgOpen, and we treat 0 as valid file descriptor. Here we should do the
 same or fail earlier.

---
 lib/backend/ndb/rpmpkg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/backend/ndb/rpmpkg.c b/lib/backend/ndb/rpmpkg.c
index 64d0493..0a041e4 100644
--- a/lib/backend/ndb/rpmpkg.c
+++ b/lib/backend/ndb/rpmpkg.c
@@ -734,7 +734,7 @@ static int rpmpkgAddSlotPage(rpmpkgdb pkgdb)
 
 static int rpmpkgGetLock(rpmpkgdb pkgdb, int type)
 {
-    if (!pkgdb->fd)
+    if (pkgdb->fd < 0)
 	return RPMRC_FAIL;
     if (flock(pkgdb->fd, type))
 	return RPMRC_FAIL;
-- 
1.8.3.1

