diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-09-26 00:09:07 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-09-26 00:09:07 +0800 |
commit | b8c1050886081df207fb30f16884c844e7e17fd9 (patch) | |
tree | 6e2a60d32b89f79c83298c1196b746bee3d3d53e /e-util | |
parent | da85df2ff6a6b9540708540ac69054a84fdf60ad (diff) | |
download | gsoc2013-evolution-b8c1050886081df207fb30f16884c844e7e17fd9.tar gsoc2013-evolution-b8c1050886081df207fb30f16884c844e7e17fd9.tar.gz gsoc2013-evolution-b8c1050886081df207fb30f16884c844e7e17fd9.tar.bz2 gsoc2013-evolution-b8c1050886081df207fb30f16884c844e7e17fd9.tar.lz gsoc2013-evolution-b8c1050886081df207fb30f16884c844e7e17fd9.tar.xz gsoc2013-evolution-b8c1050886081df207fb30f16884c844e7e17fd9.tar.zst gsoc2013-evolution-b8c1050886081df207fb30f16884c844e7e17fd9.zip |
Make sure that res->ai_canonname is non-NULL and that it doesn't match the
2003-09-25 Jeffrey Stedfast <fejj@ximian.com>
* e-host-utils.c (e_gethostbyaddr_r): Make sure that
res->ai_canonname is non-NULL and that it doesn't match the
numeric host address that we were trying to resolve. Fixes the
second half of bug #46006.
svn path=/trunk/; revision=22701
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/ChangeLog | 12 | ||||
-rw-r--r-- | e-util/e-host-utils.c | 27 |
2 files changed, 38 insertions, 1 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 21014249b5..38ee4c5d26 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,15 @@ +2003-09-25 Jeffrey Stedfast <fejj@ximian.com> + + * e-host-utils.c (e_gethostbyaddr_r): Make sure that + res->ai_canonname is non-NULL and that it doesn't match the + numeric host address that we were trying to resolve. Fixes the + second half of bug #46006. + +2003-09-19 Jeffrey Stedfast <fejj@ximian.com> + + * e-host-utils.c (e_gethostbyaddr_r): Work around a bug in glibc + 2.3.2's gethostbyaddr_r() implementation. + 2003-09-11 Dan Winship <danw@ximian.com> * Makefile.am (noinst_LTLIBRARIES): Remove libeutil-static.la and diff --git a/e-util/e-host-utils.c b/e-util/e-host-utils.c index e1a7296b3d..1d685019cc 100644 --- a/e-util/e-host-utils.c +++ b/e-util/e-host-utils.c @@ -313,6 +313,19 @@ e_gethostbyaddr_r (const char *addr, int addrlen, int type, struct hostent *host return -1; } + /* If nodename is not null, and if requested by the AI_CANONNAME flag, the ai_canonname + * field of the first returned addrinfo structure shall point to a null-terminated + * string containing the canonical name corresponding to the input nodename; if the + * canonical name is not available, then ai_canonname shall refer to the nodename + * argument or a string with the same contents. + * + * Note: NetBSD seems to set res->ai_canonname to NULL in this case instead. + */ + if (!res->ai_canonname || !strcmp (res->ai_canonname, name)) { + *herr = HOST_NOT_FOUND; + return -1; + } + len = ALIGN (strlen (res->ai_canonname) + 1); if (buflen < IPv6_BUFLEN_MIN + len + res->ai_addrlen + sizeof (char *)) return ERANGE; @@ -363,8 +376,20 @@ e_gethostbyaddr_r (const char *addr, int addrlen, int type, struct hostent *host int retval; retval = gethostbyaddr_r (addr, addrlen, type, host, buf, buflen, &hp, herr); - if (hp != NULL) + if (hp != NULL) { *herr = 0; + retval = 0; + } else if (retval == 0) { + /* glibc 2.3.2 workaround - it seems that + * gethostbyaddr_r will sometimes return 0 on fail and + * fill @host with garbage strings from /etc/hosts + * (failure to parse the file? who knows). Luckily, it + * seems that we can rely on @hp being NULL on + * fail. + */ + retval = -1; + } + return retval; #endif #else /* No support for gethostbyaddr_r */ |