diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/net/getprotoent.c | 10 |
1 files changed, 7 insertions, 3 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; |
