summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/inet/resolv.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index cfc1eee9b..31e63810b 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -1615,9 +1615,13 @@ int __read_etc_hosts_r(
#endif
;
int ret = HOST_NOT_FOUND;
+ /* make sure pointer is aligned */
+ int i = ALIGN_BUFFER_OFFSET(buf);
+ buf += i;
+ buflen -= i;
*h_errnop = NETDB_INTERNAL;
- if (buflen < aliaslen
+ if (/* (ssize_t)buflen < 0 || */ buflen < aliaslen
|| (buflen - aliaslen) < BUFSZ + 1)
return ERANGE;
if (parser == NULL)