From f7e9ff4496cc53caf8217b6210e29628ec60561d Mon Sep 17 00:00:00 2001 From: John Levon Date: Thu, 15 Apr 2021 10:42:07 +0100 Subject: vfu_ctx_create(): validate flags argument (#442) In addition, return ENOTSUP for unknown device types, and add some unit tests. Signed-off-by: John Levon Reviewed-by: Thanos Makatos --- lib/libvfio-user.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/libvfio-user.c') diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index e6b79f2..03ef6da 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -1187,14 +1187,16 @@ vfu_create_ctx(vfu_trans_t trans, const char *path, int flags, void *pvt, int err = 0; size_t i; - //FIXME: Validate arguments. + if ((flags & ~(LIBVFIO_USER_FLAG_ATTACH_NB)) != 0) { + return ERROR_PTR(EINVAL); + } if (trans != VFU_TRANS_SOCK) { return ERROR_PTR(ENOTSUP); } if (dev_type != VFU_DEV_TYPE_PCI) { - return ERROR_PTR(EINVAL); + return ERROR_PTR(ENOTSUP); } vfu_ctx = calloc(1, sizeof(vfu_ctx_t)); -- cgit v1.1