diff options
Diffstat (limited to 'src/lib/libc')
| -rw-r--r-- | src/lib/libc/net/getprotoent.c | 10 | ||||
| -rw-r--r-- | src/lib/libc/net/getservent.c | 10 | ||||
| -rw-r--r-- | src/lib/libc/net/res_init.c | 25 |
3 files changed, 29 insertions, 16 deletions
diff --git a/src/lib/libc/net/getprotoent.c b/src/lib/libc/net/getprotoent.c index 2bef526e7a..2f8b267611 100644 --- a/src/lib/libc/net/getprotoent.c +++ b/src/lib/libc/net/getprotoent.c | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
| 35 | static char rcsid[] = "$OpenBSD: getprotoent.c,v 1.3 1998/03/16 05:06:59 millert Exp $"; | 35 | static char rcsid[] = "$OpenBSD: getprotoent.c,v 1.4 1999/09/03 16:23:18 millert Exp $"; |
| 36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
| 37 | 37 | ||
| 38 | #include <sys/types.h> | 38 | #include <sys/types.h> |
| @@ -74,7 +74,8 @@ endprotoent() | |||
| 74 | struct protoent * | 74 | struct protoent * |
| 75 | getprotoent() | 75 | getprotoent() |
| 76 | { | 76 | { |
| 77 | char *p, *cp, **q; | 77 | char *p, *cp, **q, *endp; |
| 78 | long l; | ||
| 78 | size_t len; | 79 | size_t len; |
| 79 | 80 | ||
| 80 | if (protof == NULL && (protof = fopen(_PATH_PROTOCOLS, "r" )) == NULL) | 81 | if (protof == NULL && (protof = fopen(_PATH_PROTOCOLS, "r" )) == NULL) |
| @@ -102,7 +103,10 @@ again: | |||
| 102 | p = strpbrk(cp, " \t"); | 103 | p = strpbrk(cp, " \t"); |
| 103 | if (p != NULL) | 104 | if (p != NULL) |
| 104 | *p++ = '\0'; | 105 | *p++ = '\0'; |
| 105 | proto.p_proto = atoi(cp); | 106 | l = strtol(cp, &endp, 10); |
| 107 | if (endp == cp || *endp != '\0' || l < 0 || l >= INT_MAX) | ||
| 108 | goto again; | ||
| 109 | proto.p_proto = l; | ||
| 106 | q = proto.p_aliases = proto_aliases; | 110 | q = proto.p_aliases = proto_aliases; |
| 107 | if (p != NULL) { | 111 | if (p != NULL) { |
| 108 | cp = p; | 112 | cp = p; |
diff --git a/src/lib/libc/net/getservent.c b/src/lib/libc/net/getservent.c index 7d8cb6d8ca..ff6bf1e57f 100644 --- a/src/lib/libc/net/getservent.c +++ b/src/lib/libc/net/getservent.c | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
| 35 | static char rcsid[] = "$OpenBSD: getservent.c,v 1.4 1998/03/16 05:07:00 millert Exp $"; | 35 | static char rcsid[] = "$OpenBSD: getservent.c,v 1.5 1999/09/03 16:23:19 millert Exp $"; |
| 36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
| 37 | 37 | ||
| 38 | #include <sys/types.h> | 38 | #include <sys/types.h> |
| @@ -74,7 +74,8 @@ endservent() | |||
| 74 | struct servent * | 74 | struct servent * |
| 75 | getservent() | 75 | getservent() |
| 76 | { | 76 | { |
| 77 | char *p, *cp, **q; | 77 | char *p, *cp, **q, *endp; |
| 78 | long l; | ||
| 78 | size_t len; | 79 | size_t len; |
| 79 | 80 | ||
| 80 | if (servf == NULL && (servf = fopen(_PATH_SERVICES, "r" )) == NULL) | 81 | if (servf == NULL && (servf = fopen(_PATH_SERVICES, "r" )) == NULL) |
| @@ -103,7 +104,10 @@ again: | |||
| 103 | if (cp == NULL) | 104 | if (cp == NULL) |
| 104 | goto again; | 105 | goto again; |
| 105 | *cp++ = '\0'; | 106 | *cp++ = '\0'; |
| 106 | serv.s_port = htons((in_port_t)atoi(p)); | 107 | l = strtol(p, &endp, 10); |
| 108 | if (endp == p || *endp != '\0' || l < 0 || l > USHRT_MAX) | ||
| 109 | goto again; | ||
| 110 | serv.s_port = htons((in_port_t)l); | ||
| 107 | serv.s_proto = cp; | 111 | serv.s_proto = cp; |
| 108 | q = serv.s_aliases = serv_aliases; | 112 | q = serv.s_aliases = serv_aliases; |
| 109 | cp = strpbrk(cp, " \t"); | 113 | cp = strpbrk(cp, " \t"); |
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)) { |
