aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-host-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'e-util/e-host-utils.c')
-rw-r--r--e-util/e-host-utils.c15
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;