render / rpms / libvirt

Forked from rpms/libvirt 7 months ago
Clone
c480ed
From abf1be5d4639ca4b58d56633129a7cf1389b97f3 Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <abf1be5d4639ca4b58d56633129a7cf1389b97f3@dist-git>
c480ed
From: John Ferlan <jferlan@redhat.com>
c480ed
Date: Tue, 30 Jul 2019 16:04:52 +0200
c480ed
Subject: [PATCH] util: Avoid possible error in virCommandMassClose
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
Avoid the chance that sysconf(_SC_OPEN_MAX) returns -1 and thus
c480ed
would cause virBitmapNew would attempt to allocate a very large
c480ed
bitmap.
c480ed
c480ed
Found by Coverity
c480ed
c480ed
Signed-off-by: John Ferlan <jferlan@redhat.com>
c480ed
ACKed-by: Peter Krempa <pkrempa@redhat.com>
c480ed
(cherry picked from commit 6ae4f4a4ceb123417b732e869d53099983ae8d3f)
c480ed
c480ed
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1721434
c480ed
c480ed
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c480ed
Message-Id: <e17edd9e1f50630c019ec7206a0f15cd8c3e474a.1564495366.git.mprivozn@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/util/vircommand.c | 5 +++++
c480ed
 1 file changed, 5 insertions(+)
c480ed
c480ed
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
c480ed
index dfc7e5428b..c53e3f47db 100644
c480ed
--- a/src/util/vircommand.c
c480ed
+++ b/src/util/vircommand.c
c480ed
@@ -560,6 +560,11 @@ virCommandMassClose(virCommandPtr cmd,
c480ed
      * Therefore we can safely allocate memory here (and transitively call
c480ed
      * opendir/readdir) without a deadlock. */
c480ed
 
c480ed
+    if (openmax < 0) {
c480ed
+        virReportSystemError(errno, "%s", _("sysconf(_SC_OPEN_MAX) failed"));
c480ed
+        return -1;
c480ed
+    }
c480ed
+
c480ed
     if (!(fds = virBitmapNew(openmax)))
c480ed
         return -1;
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed