[Spice-devel] [PATCH linux vdagent 2/2] Avoid leaking udscs file descriptor
Frediano Ziglio
fziglio at redhat.com
Wed Nov 29 17:18:04 UTC 2017
>
> This is a finding from coverity. In practice it has very little impact
maybe Coverity (with capital) ?
> since returning NULL from this function results in the process existing
> with an error.
>
> Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
> ---
> src/udscs.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/src/udscs.c b/src/udscs.c
> index 64f0307..6e73015 100644
> --- a/src/udscs.c
> +++ b/src/udscs.c
> @@ -450,12 +450,14 @@ struct udscs_server *udscs_create_server(const char
> *socketname,
> c = bind(fd, (struct sockaddr *)&address, sizeof(address));
> if (c != 0) {
> syslog(LOG_ERR, "bind %s: %m", socketname);
> + close(fd);
> return NULL;
> }
>
> c = listen(fd, 5);
> if (c != 0) {
> syslog(LOG_ERR, "listen: %m");
> + close(fd);
> return NULL;
> }
>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
Note that there are 2 other similar paths in udscs_create_server_for_fd that does
not close the file descriptor and return NULL.
I don't consider this patch a 2/2, is quite independent.
Frediano
More information about the Spice-devel
mailing list