diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-04-25 01:05:13 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-04-25 01:05:13 +0800 |
commit | 1a3b2e594c3a2feadc3dd42394deffc96ed27c39 (patch) | |
tree | 425662d847ac7e0839c0bb635db4ae48866b31a5 /e-util/e-host-utils.c | |
parent | 960163b188ae63f7696c1222164d3aeffd67f5eb (diff) | |
download | gsoc2013-evolution-1a3b2e594c3a2feadc3dd42394deffc96ed27c39.tar.gz gsoc2013-evolution-1a3b2e594c3a2feadc3dd42394deffc96ed27c39.tar.zst gsoc2013-evolution-1a3b2e594c3a2feadc3dd42394deffc96ed27c39.zip |
Keep our buf ptr aligned to sizeof (char *). Should fix bug #41362.
2003-04-17 Jeffrey Stedfast <fejj@ximian.com>
* e-host-utils.c (e_gethostbyname_r): Keep our buf ptr aligned to
sizeof (char *). Should fix bug #41362.
(e_gethostbyaddr_r): Same.
svn path=/trunk/; revision=20956
Diffstat (limited to 'e-util/e-host-utils.c')
-rw-r--r-- | e-util/e-host-utils.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/e-util/e-host-utils.c b/e-util/e-host-utils.c index 248c22afd7..04a2c6373e 100644 --- a/e-util/e-host-utils.c +++ b/e-util/e-host-utils.c @@ -43,6 +43,8 @@ G_LOCK_DEFINE_STATIC (gethost_mutex); #endif +#define ALIGN(x) (((x) + (sizeof (char *) - 1)) & ~(sizeof (char *) - 1)) + #define GETHOST_PROCESS(h, host, buf, buflen, herr) G_STMT_START { \ int num_aliases = 0, num_addrs = 0; \ int req_length; \ @@ -153,6 +155,7 @@ ai_to_herr (int error) break; } } + #endif /* ENABLE_IPv6 */ /** @@ -189,8 +192,8 @@ e_gethostbyname_r (const char *name, struct hostent *host, return -1; } - len = strlen (res->ai_canonname); - if (buflen < IPv6_BUFLEN_MIN + len + 1 + res->ai_addrlen) + len = ALIGN (strlen (res->ai_canonname) + 1); + if (buflen < IPv6_BUFLEN_MIN + len + res->ai_addrlen + sizeof (char *)) return ERANGE; /* h_name */ @@ -217,7 +220,7 @@ e_gethostbyname_r (const char *name, struct hostent *host, memcpy (buf, addr, host->h_length); addr = buf; - buf += host->h_length; + buf += ALIGN (host->h_length); /* h_addr_list */ ((char **) buf)[0] = addr; @@ -309,8 +312,8 @@ e_gethostbyaddr_r (const char *addr, int addrlen, int type, struct hostent *host return -1; } - len = strlen (res->ai_canonname); - if (buflen < IPv6_BUFLEN_MIN + len + 1 + res->ai_addrlen) + len = ALIGN (strlen (res->ai_canonname) + 1); + if (buflen < IPv6_BUFLEN_MIN + len + res->ai_addrlen + sizeof (char *)) return ERANGE; /* h_name */ @@ -337,7 +340,7 @@ e_gethostbyaddr_r (const char *addr, int addrlen, int type, struct hostent *host memcpy (buf, addr, host->h_length); addr = buf; - buf += host->h_length; + buf += ALIGN (host->h_length); /* h_addr_list */ ((char **) buf)[0] = addr; |