Avoid the chance that sysconf(_SC_OPEN_MAX) returns -1 and thus
would cause virBitmapNew would attempt to allocate a very large
bitmap.
Found by Coverity
Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
* Therefore we can safely allocate memory here (and transitively call
* opendir/readdir) without a deadlock. */
+ if (openmax < 0) {
+ virReportSystemError(errno, "%s", _("sysconf(_SC_OPEN_MAX) failed"));
+ return -1;
+ }
+
if (!(fds = virBitmapNew(openmax)))
return -1;