diff options
author | ray <> | 2007-02-18 20:38:28 +0000 |
---|---|---|
committer | ray <> | 2007-02-18 20:38:28 +0000 |
commit | 7d44917b716412c71e8fbaeee73ac32c9187dd60 (patch) | |
tree | db029d861abec10d821c02ebea3b7a6a0c4dbfc3 /src/lib | |
parent | 4474f954bf448226bacd6b8f7906c23d4d85f092 (diff) | |
download | openbsd-7d44917b716412c71e8fbaeee73ac32c9187dd60.tar.gz openbsd-7d44917b716412c71e8fbaeee73ac32c9187dd60.tar.bz2 openbsd-7d44917b716412c71e8fbaeee73ac32c9187dd60.zip |
strlen(3) returns size_t, not int.
Suggested by itojun@ in response to my getaddrinfo fixes.
OK millert@.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libc/net/gethostnamadr.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/lib/libc/net/gethostnamadr.c b/src/lib/libc/net/gethostnamadr.c index 2f5113d5e4..cae27910d0 100644 --- a/src/lib/libc/net/gethostnamadr.c +++ b/src/lib/libc/net/gethostnamadr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: gethostnamadr.c,v 1.69 2007/02/14 10:26:35 itojun Exp $ */ | 1 | /* $OpenBSD: gethostnamadr.c,v 1.70 2007/02/18 20:38:28 ray Exp $ */ |
2 | /*- | 2 | /*- |
3 | * Copyright (c) 1985, 1988, 1993 | 3 | * Copyright (c) 1985, 1988, 1993 |
4 | * The Regents of the University of California. All rights reserved. | 4 | * The Regents of the University of California. All rights reserved. |
@@ -202,9 +202,8 @@ getanswer(const querybuf *answer, int anslen, const char *qname, int qtype) | |||
202 | * same as the one we sent; this just gets the expanded name | 202 | * same as the one we sent; this just gets the expanded name |
203 | * (i.e., with the succeeding search-domain tacked on). | 203 | * (i.e., with the succeeding search-domain tacked on). |
204 | */ | 204 | */ |
205 | n = strlen(bp) + 1; /* for the \0 */ | ||
206 | host.h_name = bp; | 205 | host.h_name = bp; |
207 | bp += n; | 206 | bp += strlen(bp) + 1; /* for the \0 */ |
208 | /* The qname can be abbreviated, but h_name is now absolute. */ | 207 | /* The qname can be abbreviated, but h_name is now absolute. */ |
209 | qname = host.h_name; | 208 | qname = host.h_name; |
210 | } | 209 | } |
@@ -217,6 +216,8 @@ getanswer(const querybuf *answer, int anslen, const char *qname, int qtype) | |||
217 | haveanswer = 0; | 216 | haveanswer = 0; |
218 | had_error = 0; | 217 | had_error = 0; |
219 | while (ancount-- > 0 && cp < eom && !had_error) { | 218 | while (ancount-- > 0 && cp < eom && !had_error) { |
219 | size_t len; | ||
220 | |||
220 | n = dn_expand(answer->buf, eom, cp, bp, ep - bp); | 221 | n = dn_expand(answer->buf, eom, cp, bp, ep - bp); |
221 | if ((n < 0) || !(*name_ok)(bp)) { | 222 | if ((n < 0) || !(*name_ok)(bp)) { |
222 | had_error++; | 223 | had_error++; |
@@ -258,17 +259,16 @@ getanswer(const querybuf *answer, int anslen, const char *qname, int qtype) | |||
258 | cp += n; | 259 | cp += n; |
259 | /* Store alias. */ | 260 | /* Store alias. */ |
260 | *ap++ = bp; | 261 | *ap++ = bp; |
261 | n = strlen(bp) + 1; /* for the \0 */ | 262 | bp += strlen(bp) + 1; /* for the \0 */ |
262 | bp += n; | ||
263 | /* Get canonical name. */ | 263 | /* Get canonical name. */ |
264 | n = strlen(tbuf) + 1; /* for the \0 */ | 264 | len = strlen(tbuf) + 1; /* for the \0 */ |
265 | if (n > ep - bp) { | 265 | if (len > ep - bp) { |
266 | had_error++; | 266 | had_error++; |
267 | continue; | 267 | continue; |
268 | } | 268 | } |
269 | strlcpy(bp, tbuf, ep - bp); | 269 | strlcpy(bp, tbuf, ep - bp); |
270 | host.h_name = bp; | 270 | host.h_name = bp; |
271 | bp += n; | 271 | bp += len; |
272 | continue; | 272 | continue; |
273 | } | 273 | } |
274 | if (qtype == T_PTR && type == T_CNAME) { | 274 | if (qtype == T_PTR && type == T_CNAME) { |
@@ -283,14 +283,14 @@ getanswer(const querybuf *answer, int anslen, const char *qname, int qtype) | |||
283 | } | 283 | } |
284 | cp += n; | 284 | cp += n; |
285 | /* Get canonical name. */ | 285 | /* Get canonical name. */ |
286 | n = strlen(tbuf) + 1; /* for the \0 */ | 286 | len = strlen(tbuf) + 1; /* for the \0 */ |
287 | if (n > ep - bp) { | 287 | if (len > ep - bp) { |
288 | had_error++; | 288 | had_error++; |
289 | continue; | 289 | continue; |
290 | } | 290 | } |
291 | strlcpy(bp, tbuf, ep - bp); | 291 | strlcpy(bp, tbuf, ep - bp); |
292 | tname = bp; | 292 | tname = bp; |
293 | bp += n; | 293 | bp += len; |
294 | continue; | 294 | continue; |
295 | } | 295 | } |
296 | if (type != qtype) { | 296 | if (type != qtype) { |
@@ -406,12 +406,14 @@ getanswer(const querybuf *answer, int anslen, const char *qname, int qtype) | |||
406 | addrsort(h_addr_ptrs, haveanswer); | 406 | addrsort(h_addr_ptrs, haveanswer); |
407 | # endif /*RESOLVSORT*/ | 407 | # endif /*RESOLVSORT*/ |
408 | if (!host.h_name) { | 408 | if (!host.h_name) { |
409 | n = strlen(qname) + 1; /* for the \0 */ | 409 | size_t len; |
410 | if (n > ep - bp) | 410 | |
411 | len = strlen(qname) + 1; | ||
412 | if (len > ep - bp) /* for the \0 */ | ||
411 | goto try_again; | 413 | goto try_again; |
412 | strlcpy(bp, qname, ep - bp); | 414 | strlcpy(bp, qname, ep - bp); |
413 | host.h_name = bp; | 415 | host.h_name = bp; |
414 | bp += n; | 416 | bp += len; |
415 | } | 417 | } |
416 | if (_resp->options & RES_USE_INET6) | 418 | if (_resp->options & RES_USE_INET6) |
417 | map_v4v6_hostent(&host, &bp, ep); | 419 | map_v4v6_hostent(&host, &bp, ep); |