qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-9.1 v3 05/11] contrib/vhost-user-blk: fix bind() using th


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH for-9.1 v3 05/11] contrib/vhost-user-blk: fix bind() using the right size of the address
Date: Thu, 4 Apr 2024 15:56:45 +0200
User-agent: Mozilla Thunderbird

On 4/4/24 14:23, Stefano Garzarella wrote:
On macOS passing `-s /tmp/vhost.socket` parameter to the vhost-user-blk
application, the bind was done on `/tmp/vhost.socke` pathname,
missing the last character.

This sounds like one of the portability problems described in the
unix(7) manpage:

    Pathname sockets
        When  binding  a socket to a pathname, a few rules should
        be observed for maximum portability and ease of coding:

        •  The pathname in sun_path should be null-terminated.

        •  The length of the pathname, including the  terminating
           null byte, should not exceed the size of sun_path.

        •  The  addrlen  argument  that  describes  the enclosing
           sockaddr_un structure should have a value of at least:

               offsetof(struct sockaddr_un, sun_path) +
               strlen(addr.sun_path)+1

           or,  more  simply,  addrlen  can   be   specified   as
           sizeof(struct sockaddr_un).

So let's follow the last advice and simplify the code as well.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
  contrib/vhost-user-blk/vhost-user-blk.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]