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