diff options
author | millert <> | 1999-09-03 16:23:19 +0000 |
---|---|---|
committer | millert <> | 1999-09-03 16:23:19 +0000 |
commit | 23b5374f8e5e1cf893e358275617ba8b58163ae7 (patch) | |
tree | 7ce15115dafea63e80fab4d6099642a83b95444e /src/lib/libc/net/res_init.c | |
parent | 16cba6f0dd5d54ed11696fbb4b172ea0e3d44036 (diff) | |
download | openbsd-23b5374f8e5e1cf893e358275617ba8b58163ae7.tar.gz openbsd-23b5374f8e5e1cf893e358275617ba8b58163ae7.tar.bz2 openbsd-23b5374f8e5e1cf893e358275617ba8b58163ae7.zip |
Use strtol() and strtoul() instead of atoi(). This allows us to catch
errors reasonably and deal correctly with unsigned quantities.
Diffstat (limited to 'src/lib/libc/net/res_init.c')
-rw-r--r-- | src/lib/libc/net/res_init.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/lib/libc/net/res_init.c b/src/lib/libc/net/res_init.c index df176b7fa1..2e8023ad31 100644 --- a/src/lib/libc/net/res_init.c +++ b/src/lib/libc/net/res_init.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: res_init.c,v 1.16 1998/03/16 05:07:01 millert Exp $ */ | 1 | /* $OpenBSD: res_init.c,v 1.17 1999/09/03 16:23:19 millert Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * ++Copyright++ 1985, 1989, 1993 | 4 | * ++Copyright++ 1985, 1989, 1993 |
@@ -60,7 +60,7 @@ | |||
60 | static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; | 60 | static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; |
61 | static char rcsid[] = "$From: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $"; | 61 | static char rcsid[] = "$From: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $"; |
62 | #else | 62 | #else |
63 | static char rcsid[] = "$OpenBSD: res_init.c,v 1.16 1998/03/16 05:07:01 millert Exp $"; | 63 | static char rcsid[] = "$OpenBSD: res_init.c,v 1.17 1999/09/03 16:23:19 millert Exp $"; |
64 | #endif | 64 | #endif |
65 | #endif /* LIBC_SCCS and not lint */ | 65 | #endif /* LIBC_SCCS and not lint */ |
66 | 66 | ||
@@ -459,7 +459,8 @@ res_setoptions(options, source) | |||
459 | char *options, *source; | 459 | char *options, *source; |
460 | { | 460 | { |
461 | char *cp = options; | 461 | char *cp = options; |
462 | int i; | 462 | char *endp; |
463 | long l; | ||
463 | 464 | ||
464 | #ifdef DEBUG | 465 | #ifdef DEBUG |
465 | if (_res.options & RES_DEBUG) | 466 | if (_res.options & RES_DEBUG) |
@@ -472,15 +473,19 @@ res_setoptions(options, source) | |||
472 | cp++; | 473 | cp++; |
473 | /* search for and process individual options */ | 474 | /* search for and process individual options */ |
474 | if (!strncmp(cp, "ndots:", sizeof("ndots:") - 1)) { | 475 | if (!strncmp(cp, "ndots:", sizeof("ndots:") - 1)) { |
475 | i = atoi(cp + sizeof("ndots:") - 1); | 476 | char *p = cp + sizeof("ndots:") - 1; |
476 | if (i <= RES_MAXNDOTS) | 477 | l = strtol(p, &endp, 10); |
477 | _res.ndots = i; | 478 | if (l >= 0 && endp != p && |
478 | else | 479 | (*endp = '\0' || issapce(*endp))) { |
479 | _res.ndots = RES_MAXNDOTS; | 480 | if (l <= RES_MAXNDOTS) |
481 | _res.ndots = l; | ||
482 | else | ||
483 | _res.ndots = RES_MAXNDOTS; | ||
480 | #ifdef DEBUG | 484 | #ifdef DEBUG |
481 | if (_res.options & RES_DEBUG) | 485 | if (_res.options & RES_DEBUG) |
482 | printf(";;\tndots=%d\n", _res.ndots); | 486 | printf(";;\tndots=%d\n", _res.ndots); |
483 | #endif | 487 | #endif |
488 | } | ||
484 | } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) { | 489 | } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) { |
485 | #ifdef DEBUG | 490 | #ifdef DEBUG |
486 | if (!(_res.options & RES_DEBUG)) { | 491 | if (!(_res.options & RES_DEBUG)) { |