net/socket: Fix invalid socket type error handling
Calling error_report() in a function that takes an Error ** argument is suspicious. net_socket_fd_init() does that, and then fails without setting an error. Wrong. I didn't analyze how exactly this can break. A caller that reports the error on failure would crash. Broken when commitc37f0bb1d0
(v2.11.0) converted the function to Error. Fix by calling error_setg() instead of error_report(). Fixes:c37f0bb1d0
Cc: Jason Wang <jasowang@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20181017082702.5581-15-armbru@redhat.com>
This commit is contained in:
parent
007e5f8782
commit
8c42dbe395
@ -453,8 +453,8 @@ static NetSocketState *net_socket_fd_init(NetClientState *peer,
|
||||
case SOCK_STREAM:
|
||||
return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
|
||||
default:
|
||||
error_report("socket type=%d for fd=%d must be either"
|
||||
" SOCK_DGRAM or SOCK_STREAM", so_type, fd);
|
||||
error_setg(errp, "socket type=%d for fd=%d must be either"
|
||||
" SOCK_DGRAM or SOCK_STREAM", so_type, fd);
|
||||
closesocket(fd);
|
||||
}
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user