diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bio/b_sock.c | 51 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/bio/b_sock.c | 51 |
2 files changed, 6 insertions, 96 deletions
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index 62d545a129..5f8b1e052f 100644 --- a/src/lib/libcrypto/bio/b_sock.c +++ b/src/lib/libcrypto/bio/b_sock.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: b_sock.c,v 1.42 2014/06/24 17:30:00 jsing Exp $ */ | 1 | /* $OpenBSD: b_sock.c,v 1.43 2014/06/24 17:42:54 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -59,6 +59,7 @@ | |||
| 59 | #include <sys/ioctl.h> | 59 | #include <sys/ioctl.h> |
| 60 | #include <sys/socket.h> | 60 | #include <sys/socket.h> |
| 61 | 61 | ||
| 62 | #include <arpa/inet.h> | ||
| 62 | #include <netinet/in.h> | 63 | #include <netinet/in.h> |
| 63 | #include <netinet/tcp.h> | 64 | #include <netinet/tcp.h> |
| 64 | 65 | ||
| @@ -72,8 +73,6 @@ | |||
| 72 | 73 | ||
| 73 | #include "cryptlib.h" | 74 | #include "cryptlib.h" |
| 74 | 75 | ||
| 75 | static int get_ip(const char *str, unsigned char *ip); | ||
| 76 | |||
| 77 | int | 76 | int |
| 78 | BIO_get_host_ip(const char *str, unsigned char *ip) | 77 | BIO_get_host_ip(const char *str, unsigned char *ip) |
| 79 | { | 78 | { |
| @@ -82,15 +81,7 @@ BIO_get_host_ip(const char *str, unsigned char *ip) | |||
| 82 | int locked = 0; | 81 | int locked = 0; |
| 83 | struct hostent *he; | 82 | struct hostent *he; |
| 84 | 83 | ||
| 85 | i = get_ip(str, ip); | 84 | if (inet_pton(AF_INET, str, ip) == 1) |
| 86 | if (i < 0) { | ||
| 87 | BIOerr(BIO_F_BIO_GET_HOST_IP, BIO_R_INVALID_IP_ADDRESS); | ||
| 88 | goto err; | ||
| 89 | } | ||
| 90 | |||
| 91 | /* If the string actually contained an IP address, we need not do | ||
| 92 | anything more */ | ||
| 93 | if (i > 0) | ||
| 94 | return (1); | 85 | return (1); |
| 95 | 86 | ||
| 96 | /* do a gethostbyname */ | 87 | /* do a gethostbyname */ |
| @@ -228,42 +219,6 @@ BIO_socket_ioctl(int fd, long type, void *arg) | |||
| 228 | return (i); | 219 | return (i); |
| 229 | } | 220 | } |
| 230 | 221 | ||
| 231 | /* The reason I have implemented this instead of using sscanf is because | ||
| 232 | * Visual C 1.52c gives an unresolved external when linking a DLL :-( */ | ||
| 233 | static int | ||
| 234 | get_ip(const char *str, unsigned char ip[4]) | ||
| 235 | { | ||
| 236 | unsigned int tmp[4]; | ||
| 237 | int num = 0, c, ok = 0; | ||
| 238 | |||
| 239 | tmp[0] = tmp[1] = tmp[2] = tmp[3] = 0; | ||
| 240 | |||
| 241 | for (;;) { | ||
| 242 | c= *(str++); | ||
| 243 | if ((c >= '0') && (c <= '9')) { | ||
| 244 | ok = 1; | ||
| 245 | tmp[num] = tmp[num]*10 + c-'0'; | ||
| 246 | if (tmp[num] > 255) | ||
| 247 | return (0); | ||
| 248 | } else if (c == '.') { | ||
| 249 | if (!ok) | ||
| 250 | return (-1); | ||
| 251 | if (num == 3) | ||
| 252 | return (0); | ||
| 253 | num++; | ||
| 254 | ok = 0; | ||
| 255 | } else if (c == '\0' && (num == 3) && ok) | ||
| 256 | break; | ||
| 257 | else | ||
| 258 | return (0); | ||
| 259 | } | ||
| 260 | ip[0] = tmp[0]; | ||
| 261 | ip[1] = tmp[1]; | ||
| 262 | ip[2] = tmp[2]; | ||
| 263 | ip[3] = tmp[3]; | ||
| 264 | return (1); | ||
| 265 | } | ||
| 266 | |||
| 267 | int | 222 | int |
| 268 | BIO_get_accept_socket(char *host, int bind_mode) | 223 | BIO_get_accept_socket(char *host, int bind_mode) |
| 269 | { | 224 | { |
diff --git a/src/lib/libssl/src/crypto/bio/b_sock.c b/src/lib/libssl/src/crypto/bio/b_sock.c index 62d545a129..5f8b1e052f 100644 --- a/src/lib/libssl/src/crypto/bio/b_sock.c +++ b/src/lib/libssl/src/crypto/bio/b_sock.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: b_sock.c,v 1.42 2014/06/24 17:30:00 jsing Exp $ */ | 1 | /* $OpenBSD: b_sock.c,v 1.43 2014/06/24 17:42:54 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -59,6 +59,7 @@ | |||
| 59 | #include <sys/ioctl.h> | 59 | #include <sys/ioctl.h> |
| 60 | #include <sys/socket.h> | 60 | #include <sys/socket.h> |
| 61 | 61 | ||
| 62 | #include <arpa/inet.h> | ||
| 62 | #include <netinet/in.h> | 63 | #include <netinet/in.h> |
| 63 | #include <netinet/tcp.h> | 64 | #include <netinet/tcp.h> |
| 64 | 65 | ||
| @@ -72,8 +73,6 @@ | |||
| 72 | 73 | ||
| 73 | #include "cryptlib.h" | 74 | #include "cryptlib.h" |
| 74 | 75 | ||
| 75 | static int get_ip(const char *str, unsigned char *ip); | ||
| 76 | |||
| 77 | int | 76 | int |
| 78 | BIO_get_host_ip(const char *str, unsigned char *ip) | 77 | BIO_get_host_ip(const char *str, unsigned char *ip) |
| 79 | { | 78 | { |
| @@ -82,15 +81,7 @@ BIO_get_host_ip(const char *str, unsigned char *ip) | |||
| 82 | int locked = 0; | 81 | int locked = 0; |
| 83 | struct hostent *he; | 82 | struct hostent *he; |
| 84 | 83 | ||
| 85 | i = get_ip(str, ip); | 84 | if (inet_pton(AF_INET, str, ip) == 1) |
| 86 | if (i < 0) { | ||
| 87 | BIOerr(BIO_F_BIO_GET_HOST_IP, BIO_R_INVALID_IP_ADDRESS); | ||
| 88 | goto err; | ||
| 89 | } | ||
| 90 | |||
| 91 | /* If the string actually contained an IP address, we need not do | ||
| 92 | anything more */ | ||
| 93 | if (i > 0) | ||
| 94 | return (1); | 85 | return (1); |
| 95 | 86 | ||
| 96 | /* do a gethostbyname */ | 87 | /* do a gethostbyname */ |
| @@ -228,42 +219,6 @@ BIO_socket_ioctl(int fd, long type, void *arg) | |||
| 228 | return (i); | 219 | return (i); |
| 229 | } | 220 | } |
| 230 | 221 | ||
| 231 | /* The reason I have implemented this instead of using sscanf is because | ||
| 232 | * Visual C 1.52c gives an unresolved external when linking a DLL :-( */ | ||
| 233 | static int | ||
| 234 | get_ip(const char *str, unsigned char ip[4]) | ||
| 235 | { | ||
| 236 | unsigned int tmp[4]; | ||
| 237 | int num = 0, c, ok = 0; | ||
| 238 | |||
| 239 | tmp[0] = tmp[1] = tmp[2] = tmp[3] = 0; | ||
| 240 | |||
| 241 | for (;;) { | ||
| 242 | c= *(str++); | ||
| 243 | if ((c >= '0') && (c <= '9')) { | ||
| 244 | ok = 1; | ||
| 245 | tmp[num] = tmp[num]*10 + c-'0'; | ||
| 246 | if (tmp[num] > 255) | ||
| 247 | return (0); | ||
| 248 | } else if (c == '.') { | ||
| 249 | if (!ok) | ||
| 250 | return (-1); | ||
| 251 | if (num == 3) | ||
| 252 | return (0); | ||
| 253 | num++; | ||
| 254 | ok = 0; | ||
| 255 | } else if (c == '\0' && (num == 3) && ok) | ||
| 256 | break; | ||
| 257 | else | ||
| 258 | return (0); | ||
| 259 | } | ||
| 260 | ip[0] = tmp[0]; | ||
| 261 | ip[1] = tmp[1]; | ||
| 262 | ip[2] = tmp[2]; | ||
| 263 | ip[3] = tmp[3]; | ||
| 264 | return (1); | ||
| 265 | } | ||
| 266 | |||
| 267 | int | 222 | int |
| 268 | BIO_get_accept_socket(char *host, int bind_mode) | 223 | BIO_get_accept_socket(char *host, int bind_mode) |
| 269 | { | 224 | { |
