summaryrefslogtreecommitdiff
path: root/lib/libc/net/gethostnamadr.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-08-05 15:58:03 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-08-05 15:58:03 +0000
commiteab91235fe54ebf066133799987dcfc17ede044d (patch)
tree91955f70df927dcf987d8d0f2a250013f86c7a67 /lib/libc/net/gethostnamadr.c
parent76a9357e18e95fb9a757d7de62d96811d695472a (diff)
truncate h_name and h_aliases[] to MAXHOSTNAMELEN
Diffstat (limited to 'lib/libc/net/gethostnamadr.c')
-rw-r--r--lib/libc/net/gethostnamadr.c12
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++;