]> xenbits.xensource.com Git - libvirt.git/commitdiff
virExec: avoid undefined behavior
authorEric Blake <eblake@redhat.com>
Fri, 3 Dec 2010 22:02:01 +0000 (15:02 -0700)
committerEric Blake <eblake@redhat.com>
Fri, 10 Dec 2010 21:18:57 +0000 (14:18 -0700)
* src/util/util.c (__virExec): Don't use FD_ISSET on out-of-bounds fd.

src/util/util.c

index 79ca5d3e8a8ebbdd6ad49cea42edc3a7a9578c57..1b5bc68d68f74f8a47af928ba50d845a7b54a849 100644 (file)
@@ -570,8 +570,7 @@ __virExec(const char *const*argv,
             i != null &&
             i != childout &&
             i != childerr &&
-            (!keepfd ||
-             !FD_ISSET(i, keepfd))) {
+            (!keepfd || (i < FD_SETSIZE && !FD_ISSET(i, keepfd)))) {
             tmpfd = i;
             VIR_FORCE_CLOSE(tmpfd);
         }