sockets: avoid crash when cleaning up sockets for an invalid FD
PATCH 1/1 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 <[email protected]>
Signed-off-by Daniel P. Berrange <[email protected]>
--- util/qemu-sockets.c | 3 +++ 1 file changed, 3 insertions(+)
util/qemu-sockets.c +3 -0
@@ -1073,6 +1073,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) {
Signature · 1 line
2.13.6
Quoted 6 lines · * Daniel P. Berrange ([email protected]) wrote:
If
socket_listen_cleanupis passed an invalid FD, then querying the socket local address will fail. We must thus be prepared for the returned addr to be NULLReported-by Dr. David Alan Gilbert <[email protected]>Signed-off-by Daniel P. Berrange <[email protected]>
Reviewed-by Dr. David Alan Gilbert <[email protected]>
Quoted 21 lines
--- util/qemu-sockets.c | 3 +++ 1 file changed, 3 insertions(+)util/qemu-sockets.c +3
-0@@ -1073,6 +1073,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) {Signature · 1 line
2.13.6
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK