summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorderaadt <>1996-08-05 15:58:02 +0000
committerderaadt <>1996-08-05 15:58:02 +0000
commit5a58fd166c74849bfb2cf8de982fe15a3d064852 (patch)
tree890fd592bf2bfbb953455f9368a97ba8ab2ab842 /src
parent81c42da8eab8db75b274dfad67c774e1de33b4b7 (diff)
downloadopenbsd-5a58fd166c74849bfb2cf8de982fe15a3d064852.tar.gz
openbsd-5a58fd166c74849bfb2cf8de982fe15a3d064852.tar.bz2
openbsd-5a58fd166c74849bfb2cf8de982fe15a3d064852.zip
truncate h_name and h_aliases[] to MAXHOSTNAMELEN
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/net/gethostnamadr.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/libc/net/gethostnamadr.c b/src/lib/libc/net/gethostnamadr.c
index a1fdba5f91..29705f7e9e 100644
--- a/src/lib/libc/net/gethostnamadr.c
+++ b/src/lib/libc/net/gethostnamadr.c
@@ -151,7 +151,10 @@ getanswer(answer, anslen, iquery)
151 } 151 }
152 cp += n + QFIXEDSZ; 152 cp += n + QFIXEDSZ;
153 host.h_name = bp; 153 host.h_name = bp;
154 n = strlen(bp) + 1; 154 n = strlen(bp);
155 if (n >= MAXHOSTNAMELEN)
156 host.h_name[MAXHOSTNAMELEN-1] = '\0';
157 n++;
155 bp += n; 158 bp += n;
156 buflen -= n; 159 buflen -= n;
157 } else 160 } else
@@ -200,6 +203,9 @@ getanswer(answer, anslen, iquery)
200 break; 203 break;
201 cp += n; 204 cp += n;
202 host.h_name = bp; 205 host.h_name = bp;
206 n = strlen(host.h_name);
207 if (n >= MAXHOSTNAMELEN)
208 host.h_name[MAXHOSTNAMELEN-1] = '\0';
203 return(&host); 209 return(&host);
204 } 210 }
205 if (iquery || type != T_A) { 211 if (iquery || type != T_A) {
@@ -226,6 +232,8 @@ getanswer(answer, anslen, iquery)
226 host.h_addrtype = (class == C_IN) ? AF_INET : AF_UNSPEC; 232 host.h_addrtype = (class == C_IN) ? AF_INET : AF_UNSPEC;
227 if (!iquery) { 233 if (!iquery) {
228 host.h_name = bp; 234 host.h_name = bp;
235 if (strlen(bp) >= MAXHOSTNAMELEN)
236 host.h_name[MAXHOSTNAMELEN-1] = '\0';
229 bp += strlen(bp) + 1; 237 bp += strlen(bp) + 1;
230 } 238 }
231 } 239 }
@@ -240,6 +248,8 @@ getanswer(answer, anslen, iquery)
240 break; 248 break;
241 } 249 }
242 bcopy(cp, *hap++ = bp, n); 250 bcopy(cp, *hap++ = bp, n);
251 if (n >= MAXHOSTNAMELEN)
252 bp[MAXHOSTNAMELEN-1] = '\0';
243 bp +=n; 253 bp +=n;
244 cp += n; 254 cp += n;
245 haveanswer++; 255 haveanswer++;