]> xenbits.xensource.com Git - people/jgross/xen.git/commitdiff
tools/libxenevtchn: check xenevtchn_open() flags for not supported bits
authorJuergen Gross <jgross@suse.com>
Fri, 15 Jan 2021 08:29:36 +0000 (09:29 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 15 Jan 2021 11:44:47 +0000 (11:44 +0000)
Refuse a call of xenevtchn_open() with unsupported bits in flags being
set.

This will change behavior for callers passing junk in flags today,
but those would otherwise get probably unwanted side effects when the
flags they specify today get any meaning. So checking flags is the
right thing to do.

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libs/evtchn/core.c

index 72d92e28bf462a0c3160e0ec9413e5cc7cd99472..79990d0027d313a7b034a8ccbc5f3af7240da8d0 100644 (file)
@@ -13,6 +13,7 @@
  * License along with this library; If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
 
@@ -31,9 +32,16 @@ static int all_restrict_cb(Xentoolcore__Active_Handle *ah, domid_t domid)
 
 xenevtchn_handle *xenevtchn_open(xentoollog_logger *logger, unsigned int flags)
 {
-    xenevtchn_handle *xce = malloc(sizeof(*xce));
+    xenevtchn_handle *xce;
     int rc;
 
+    if ( flags )
+    {
+        errno = EINVAL;
+        return NULL;
+    }
+
+    xce = malloc(sizeof(*xce));
     if ( !xce )
         return NULL;