render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
d759b5
From 78713fc280ae0cb18e389ff9ba1eee97eedb7050 Mon Sep 17 00:00:00 2001
d759b5
Message-Id: <78713fc280ae0cb18e389ff9ba1eee97eedb7050@dist-git>
e00e43
From: John Ferlan <jferlan@redhat.com>
e00e43
Date: Wed, 9 Oct 2019 14:27:46 +0200
e00e43
Subject: [PATCH] util: Avoid possible error in virCommandMassClose
e00e43
e00e43
Avoid the chance that sysconf(_SC_OPEN_MAX) returns -1 and thus
e00e43
would cause virBitmapNew would attempt to allocate a very large
e00e43
bitmap.
e00e43
e00e43
Found by Coverity
e00e43
e00e43
Signed-off-by: John Ferlan <jferlan@redhat.com>
e00e43
ACKed-by: Peter Krempa <pkrempa@redhat.com>
e00e43
(cherry picked from commit 6ae4f4a4ceb123417b732e869d53099983ae8d3f)
e00e43
e00e43
https://bugzilla.redhat.com/show_bug.cgi?id=1759904
e00e43
e00e43
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
e00e43
Message-Id: <69ca4c7bcf0e3c7588fad50d68dbf75180109b31.1570623892.git.mprivozn@redhat.com>
e00e43
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
e00e43
---
e00e43
 src/util/vircommand.c | 5 +++++
e00e43
 1 file changed, 5 insertions(+)
e00e43
e00e43
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
e00e43
index 17405ceea4..083a8bbee5 100644
e00e43
--- a/src/util/vircommand.c
e00e43
+++ b/src/util/vircommand.c
e00e43
@@ -561,6 +561,11 @@ virCommandMassClose(virCommandPtr cmd,
e00e43
      * Therefore we can safely allocate memory here (and transitively call
e00e43
      * opendir/readdir) without a deadlock. */
e00e43
 
e00e43
+    if (openmax < 0) {
e00e43
+        virReportSystemError(errno, "%s", _("sysconf(_SC_OPEN_MAX) failed"));
e00e43
+        return -1;
e00e43
+    }
e00e43
+
e00e43
     if (!(fds = virBitmapNew(openmax)))
e00e43
         return -1;
e00e43
 
e00e43
-- 
e00e43
2.23.0
e00e43