diff options
author | 1996-08-05 15:58:02 +0000 | |
---|---|---|
committer | 1996-08-05 15:58:02 +0000 | |
commit | 699e9a8402c1af27b205fb0ef68d27f347de6ff6 (patch) | |
tree | 976ad81f35196d74c910346824d59b6e4f6137e0 | |
parent | check for port 20 (diff) | |
download | wireguard-openbsd-699e9a8402c1af27b205fb0ef68d27f347de6ff6.tar.xz wireguard-openbsd-699e9a8402c1af27b205fb0ef68d27f347de6ff6.zip |
truncate h_name and h_aliases[] to MAXHOSTNAMELEN
-rw-r--r-- | lib/libc/net/gethostnamadr.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c index a1fdba5f917..29705f7e9e3 100644 --- a/lib/libc/net/gethostnamadr.c +++ b/lib/libc/net/gethostnamadr.c @@ -151,7 +151,10 @@ getanswer(answer, anslen, iquery) } cp += n + QFIXEDSZ; host.h_name = bp; - n = strlen(bp) + 1; + n = strlen(bp); + if (n >= MAXHOSTNAMELEN) + host.h_name[MAXHOSTNAMELEN-1] = '\0'; + n++; bp += n; buflen -= n; } else @@ -200,6 +203,9 @@ getanswer(answer, anslen, iquery) break; cp += n; host.h_name = bp; + n = strlen(host.h_name); + if (n >= MAXHOSTNAMELEN) + host.h_name[MAXHOSTNAMELEN-1] = '\0'; return(&host); } if (iquery || type != T_A) { @@ -226,6 +232,8 @@ getanswer(answer, anslen, iquery) host.h_addrtype = (class == C_IN) ? AF_INET : AF_UNSPEC; if (!iquery) { host.h_name = bp; + if (strlen(bp) >= MAXHOSTNAMELEN) + host.h_name[MAXHOSTNAMELEN-1] = '\0'; bp += strlen(bp) + 1; } } @@ -240,6 +248,8 @@ getanswer(answer, anslen, iquery) break; } bcopy(cp, *hap++ = bp, n); + if (n >= MAXHOSTNAMELEN) + bp[MAXHOSTNAMELEN-1] = '\0'; bp +=n; cp += n; haveanswer++; |