]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
tests/vhost-user-bridge.c: Sanity check socket path length
authorPeter Maydell <peter.maydell@linaro.org>
Wed, 1 Sep 2021 15:26:32 +0000 (16:26 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Sat, 4 Sep 2021 21:34:05 +0000 (17:34 -0400)
The vhost-user-bridge binary accepts a UNIX socket path on
the command line. Sanity check that this is short enough to
fit into a sockaddr_un before copying it in.

Fixes: Coverity CID 1432866
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20210901152632.25511-1-peter.maydell@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
tests/vhost-user-bridge.c

index 24815920b2ba20c87ce18c38430c281c789b5572..cb009545fa51010b5e12d10e3c0766ecd69c584d 100644 (file)
@@ -540,6 +540,11 @@ vubr_new(const char *path, bool client)
     CallbackFunc cb;
     size_t len;
 
+    if (strlen(path) >= sizeof(un.sun_path)) {
+        fprintf(stderr, "unix domain socket path '%s' is too long\n", path);
+        exit(1);
+    }
+
     /* Get a UNIX socket. */
     dev->sock = socket(AF_UNIX, SOCK_STREAM, 0);
     if (dev->sock == -1) {