render / rpms / libvirt

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