[Spice-devel] [PATCH 1/2] spice client: fix dns lookup
Uri Lublin
uril at redhat.com
Sun Feb 21 04:24:25 PST 2010
On 02/19/2010 01:21 PM, Gerd Hoffmann wrote:
> ignore lookup results which are not ipv4
>
> Signed-off-by: Gerd Hoffmann<kraxel at redhat.com>
> ---
> client/red_peer.cpp | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/client/red_peer.cpp b/client/red_peer.cpp
> index bdbf1ff..f252ef2 100644
> --- a/client/red_peer.cpp
> +++ b/client/red_peer.cpp
> @@ -77,6 +77,8 @@ uint32_t RedPeer::host_by_name(const char* host)
> int rc;
>
> rc = getaddrinfo(host, NULL, NULL,&result);
> + while (result != NULL&& result->ai_family != PF_INET)
> + result = result->ai_next;
> if (rc != 0 || result == NULL) {
> THROW_ERR(SPICEC_ERROR_CODE_GETHOSTBYNAME_FAILED, "cannot resolve host address %s", host);
> }
Changing result may cause freeaddrinfo(result) to free the wrong pointer.
Maybe better to introduce another variable here (instead of in the next patch).
More information about the Spice-devel
mailing list