sockets: avoid crash when cleaning up sockets for an invalid FD

If socket_listen_cleanup is passed an invalid FD, then querying the socket
local address will fail. We must thus be prepared for the returned addr to
be NULL

Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2017-10-27 08:51:59 +01:00
parent 5e19aed59a
commit 2d7ad7c05e

View File

@ -1079,6 +1079,9 @@ void socket_listen_cleanup(int fd, Error **errp)
SocketAddress *addr;
addr = socket_local_address(fd, errp);
if (!addr) {
return;
}
if (addr->type == SOCKET_ADDRESS_TYPE_UNIX
&& addr->u.q_unix.path) {