Re: [evolution-patches] if getaddrinfo() fails, set an exception



committed to cvs (both branches)

On Tue, 2004-10-05 at 13:45 -0400, Jeffrey Stedfast wrote:
> new patch, I think this addresses your issues with both this patch and
> the myhints compile warning patch.
> 
> Jeff
> 
> Plain text document attachment (getaddrinfo-ex.patch)
> ? 67028.patch
> ? camel-tls.patch
> ? getaddrinfo-ex.patch
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
> retrieving revision 1.2251.2.12
> diff -u -r1.2251.2.12 ChangeLog
> --- ChangeLog	29 Sep 2004 01:57:11 -0000	1.2251.2.12
> +++ ChangeLog	5 Oct 2004 17:43:56 -0000
> @@ -1,3 +1,15 @@
> +2004-10-05  Jeffrey Stedfast  <fejj novell com>
> +
> +	* camel-service.c (camel_getaddrinfo): Check msg->result for error
> +	and set an exception if appropriate.
> +	(camel_getnameinfo): Same.
> +
> +2004-10-04  Jeffrey Stedfast  <fejj novell com>
> +
> +	* camel-service.c (camel_getaddrinfo): Add a non-const cast for
> +	hints when changing the ai_family member in the IPv6-disabled
> +	case. Fixes bug #67028.
> +
>  2004-09-28  Not Zed  <NotZed Ximian com>
>  
>  	** See bug #66509.
> Index: camel-service.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/camel/camel-service.c,v
> retrieving revision 1.90.14.1
> diff -u -r1.90.14.1 camel-service.c
> --- camel-service.c	23 Sep 2004 04:12:29 -0000	1.90.14.1
> +++ camel-service.c	5 Oct 2004 17:43:56 -0000
> @@ -32,6 +32,7 @@
>  #include <stdlib.h>
>  #include <string.h>
>  #include <pthread.h>
> +#include <netdb.h>
>  #include <errno.h>
>  
>  #include <sys/poll.h>
> @@ -739,7 +740,7 @@
>  			d(printf("child done\n"));
>  		}
>  	} else {
> -		camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s: %s", _("cannot create thread"), g_strerror(err));
> +		camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s: %s: %s", error, _("cannot create thread"), g_strerror(err));
>  	}
>  	e_msgport_destroy(reply_port);
>  
> @@ -879,7 +880,7 @@
>  	struct _addrinfo_msg *msg;
>  	struct addrinfo *res = NULL;
>  #ifndef ENABLE_IPv6
> -	struct addrinfo *myhints;
> +	struct addrinfo myhints;
>  #endif
>  	g_return_val_if_fail(name != NULL, NULL);
>  	
> @@ -892,12 +893,13 @@
>  
>  	/* force ipv4 addresses only */
>  #ifndef ENABLE_IPv6
> -	if (hints == NULL) {
> +	if (hints == NULL)
>  		memset(&myhints, 0, sizeof(myhints));
> -		hints = &myhints;
> -	}
> -
> -	hints->ai_family = AF_INET;
> +	else
> +		memcpy (&myhints, hints, sizeof (myhints));
> +	
> +	myhints.ai_faimily = AF_INET;
> +	hints = &myhints;
>  #endif
>  
>  	msg = g_malloc0(sizeof(*msg));
> @@ -909,9 +911,13 @@
>  	msg->hostbuflen = 1024;
>  	msg->hostbufmem = g_malloc(msg->hostbuflen);
>  #endif	
> -	if (cs_waitinfo(cs_getaddrinfo, msg, _("Host lookup failed"), ex) == 0)
> +	if (cs_waitinfo(cs_getaddrinfo, msg, _("Host lookup failed"), ex) == 0) {
> +		if (msg->result != 0)
> +			camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Host lookup failed: %s: %s"),
> +					      name, gai_strerror (msg->result));
> +		
>  		cs_freeinfo(msg);
> -	else
> +	} else
>  		res = NULL;
>  
>  	camel_operation_end(NULL);
> @@ -1038,7 +1044,9 @@
>  #endif
>  	cs_waitinfo(cs_getnameinfo, msg, _("Name lookup failed"), ex);
>  
> -	result = msg->result;
> +	if ((result = msg->result) != 0)
> +		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Name lookup failed: %s"),
> +				      gai_strerror (result));
>  
>  	if (host)
>  		*host = g_strdup(msg->host);
-- 
Jeffrey Stedfast
Evolution Hacker - Novell, Inc.
fejj ximian com  - www.novell.com

Attachment: smime.p7s
Description: S/MIME cryptographic signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]