diff options
| author | Peter Maydell | 2021-09-01 17:26:32 +0200 |
|---|---|---|
| committer | Michael S. Tsirkin | 2021-09-04 23:34:05 +0200 |
| commit | f88435148dd38a9c609de348abc9ae231f2dbfc0 (patch) | |
| tree | 2492a0e0ebbb1464b12fae99eeb066cc68268a9e | |
| parent | hw/virtio: Add flatview update in vhost_user_cleanup() (diff) | |
| download | qemu-f88435148dd38a9c609de348abc9ae231f2dbfc0.tar.gz qemu-f88435148dd38a9c609de348abc9ae231f2dbfc0.tar.xz qemu-f88435148dd38a9c609de348abc9ae231f2dbfc0.zip | |
tests/vhost-user-bridge.c: Sanity check socket path length
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>
| -rw-r--r-- | tests/vhost-user-bridge.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c index 24815920b2..cb009545fa 100644 --- a/tests/vhost-user-bridge.c +++ b/tests/vhost-user-bridge.c @@ -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) { |
