aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-04-25 01:05:13 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-04-25 01:05:13 +0800
commit1a3b2e594c3a2feadc3dd42394deffc96ed27c39 (patch)
tree425662d847ac7e0839c0bb635db4ae48866b31a5
parent960163b188ae63f7696c1222164d3aeffd67f5eb (diff)
downloadgsoc2013-evolution-1a3b2e594c3a2feadc3dd42394deffc96ed27c39.tar
gsoc2013-evolution-1a3b2e594c3a2feadc3dd42394deffc96ed27c39.tar.gz
gsoc2013-evolution-1a3b2e594c3a2feadc3dd42394deffc96ed27c39.tar.bz2
gsoc2013-evolution-1a3b2e594c3a2feadc3dd42394deffc96ed27c39.tar.lz
gsoc2013-evolution-1a3b2e594c3a2feadc3dd42394deffc96ed27c39.tar.xz
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
-rw-r--r--e-util/ChangeLog6
-rw-r--r--e-util/e-host-utils.c15
2 files changed, 15 insertions, 6 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index d678a2fdd8..a146b260d6 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
2003-04-18 Anna Marie Dirks <anna@ximian.com>
* e-request.c (e_request_string): Added appropriate spacing/padding
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;