diff options
Diffstat (limited to 'src/lib/libcrypto/bio/b_sock.c')
-rw-r--r-- | src/lib/libcrypto/bio/b_sock.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index 6409f98f57..64310058b4 100644 --- a/src/lib/libcrypto/bio/b_sock.c +++ b/src/lib/libcrypto/bio/b_sock.c | |||
@@ -105,17 +105,22 @@ int BIO_get_host_ip(const char *str, unsigned char *ip) | |||
105 | struct hostent *he; | 105 | struct hostent *he; |
106 | 106 | ||
107 | i=get_ip(str,ip); | 107 | i=get_ip(str,ip); |
108 | if (i > 0) return(1); | ||
109 | if (i < 0) | 108 | if (i < 0) |
110 | { | 109 | { |
111 | BIOerr(BIO_F_BIO_GET_HOST_IP,BIO_R_INVALID_IP_ADDRESS); | 110 | BIOerr(BIO_F_BIO_GET_HOST_IP,BIO_R_INVALID_IP_ADDRESS); |
112 | goto err; | 111 | goto err; |
113 | } | 112 | } |
114 | 113 | ||
115 | /* do a gethostbyname */ | 114 | /* At this point, we have something that is most probably correct |
115 | in some way, so let's init the socket. */ | ||
116 | if (!BIO_sock_init()) | 116 | if (!BIO_sock_init()) |
117 | return(0); /* don't generate another error code here */ | 117 | return(0); /* don't generate another error code here */ |
118 | 118 | ||
119 | /* If the string actually contained an IP address, we need not do | ||
120 | anything more */ | ||
121 | if (i > 0) return(1); | ||
122 | |||
123 | /* do a gethostbyname */ | ||
119 | CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME); | 124 | CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME); |
120 | locked = 1; | 125 | locked = 1; |
121 | he=BIO_gethostbyname(str); | 126 | he=BIO_gethostbyname(str); |
@@ -267,14 +272,14 @@ static struct hostent *ghbn_dup(struct hostent *a) | |||
267 | int i,j; | 272 | int i,j; |
268 | 273 | ||
269 | MemCheck_off(); | 274 | MemCheck_off(); |
270 | ret=(struct hostent *)Malloc(sizeof(struct hostent)); | 275 | ret=(struct hostent *)OPENSSL_malloc(sizeof(struct hostent)); |
271 | if (ret == NULL) return(NULL); | 276 | if (ret == NULL) return(NULL); |
272 | memset(ret,0,sizeof(struct hostent)); | 277 | memset(ret,0,sizeof(struct hostent)); |
273 | 278 | ||
274 | for (i=0; a->h_aliases[i] != NULL; i++) | 279 | for (i=0; a->h_aliases[i] != NULL; i++) |
275 | ; | 280 | ; |
276 | i++; | 281 | i++; |
277 | ret->h_aliases = (char **)Malloc(i*sizeof(char *)); | 282 | ret->h_aliases = (char **)OPENSSL_malloc(i*sizeof(char *)); |
278 | if (ret->h_aliases == NULL) | 283 | if (ret->h_aliases == NULL) |
279 | goto err; | 284 | goto err; |
280 | memset(ret->h_aliases, 0, i*sizeof(char *)); | 285 | memset(ret->h_aliases, 0, i*sizeof(char *)); |
@@ -282,25 +287,25 @@ static struct hostent *ghbn_dup(struct hostent *a) | |||
282 | for (i=0; a->h_addr_list[i] != NULL; i++) | 287 | for (i=0; a->h_addr_list[i] != NULL; i++) |
283 | ; | 288 | ; |
284 | i++; | 289 | i++; |
285 | ret->h_addr_list=(char **)Malloc(i*sizeof(char *)); | 290 | ret->h_addr_list=(char **)OPENSSL_malloc(i*sizeof(char *)); |
286 | if (ret->h_addr_list == NULL) | 291 | if (ret->h_addr_list == NULL) |
287 | goto err; | 292 | goto err; |
288 | memset(ret->h_addr_list, 0, i*sizeof(char *)); | 293 | memset(ret->h_addr_list, 0, i*sizeof(char *)); |
289 | 294 | ||
290 | j=strlen(a->h_name)+1; | 295 | j=strlen(a->h_name)+1; |
291 | if ((ret->h_name=Malloc(j)) == NULL) goto err; | 296 | if ((ret->h_name=OPENSSL_malloc(j)) == NULL) goto err; |
292 | memcpy((char *)ret->h_name,a->h_name,j); | 297 | memcpy((char *)ret->h_name,a->h_name,j); |
293 | for (i=0; a->h_aliases[i] != NULL; i++) | 298 | for (i=0; a->h_aliases[i] != NULL; i++) |
294 | { | 299 | { |
295 | j=strlen(a->h_aliases[i])+1; | 300 | j=strlen(a->h_aliases[i])+1; |
296 | if ((ret->h_aliases[i]=Malloc(j)) == NULL) goto err; | 301 | if ((ret->h_aliases[i]=OPENSSL_malloc(j)) == NULL) goto err; |
297 | memcpy(ret->h_aliases[i],a->h_aliases[i],j); | 302 | memcpy(ret->h_aliases[i],a->h_aliases[i],j); |
298 | } | 303 | } |
299 | ret->h_length=a->h_length; | 304 | ret->h_length=a->h_length; |
300 | ret->h_addrtype=a->h_addrtype; | 305 | ret->h_addrtype=a->h_addrtype; |
301 | for (i=0; a->h_addr_list[i] != NULL; i++) | 306 | for (i=0; a->h_addr_list[i] != NULL; i++) |
302 | { | 307 | { |
303 | if ((ret->h_addr_list[i]=Malloc(a->h_length)) == NULL) | 308 | if ((ret->h_addr_list[i]=OPENSSL_malloc(a->h_length)) == NULL) |
304 | goto err; | 309 | goto err; |
305 | memcpy(ret->h_addr_list[i],a->h_addr_list[i],a->h_length); | 310 | memcpy(ret->h_addr_list[i],a->h_addr_list[i],a->h_length); |
306 | } | 311 | } |
@@ -325,17 +330,17 @@ static void ghbn_free(struct hostent *a) | |||
325 | if (a->h_aliases != NULL) | 330 | if (a->h_aliases != NULL) |
326 | { | 331 | { |
327 | for (i=0; a->h_aliases[i] != NULL; i++) | 332 | for (i=0; a->h_aliases[i] != NULL; i++) |
328 | Free(a->h_aliases[i]); | 333 | OPENSSL_free(a->h_aliases[i]); |
329 | Free(a->h_aliases); | 334 | OPENSSL_free(a->h_aliases); |
330 | } | 335 | } |
331 | if (a->h_addr_list != NULL) | 336 | if (a->h_addr_list != NULL) |
332 | { | 337 | { |
333 | for (i=0; a->h_addr_list[i] != NULL; i++) | 338 | for (i=0; a->h_addr_list[i] != NULL; i++) |
334 | Free(a->h_addr_list[i]); | 339 | OPENSSL_free(a->h_addr_list[i]); |
335 | Free(a->h_addr_list); | 340 | OPENSSL_free(a->h_addr_list); |
336 | } | 341 | } |
337 | if (a->h_name != NULL) Free(a->h_name); | 342 | if (a->h_name != NULL) OPENSSL_free(a->h_name); |
338 | Free(a); | 343 | OPENSSL_free(a); |
339 | } | 344 | } |
340 | 345 | ||
341 | struct hostent *BIO_gethostbyname(const char *name) | 346 | struct hostent *BIO_gethostbyname(const char *name) |
@@ -628,7 +633,7 @@ again: | |||
628 | } | 633 | } |
629 | ret=1; | 634 | ret=1; |
630 | err: | 635 | err: |
631 | if (str != NULL) Free(str); | 636 | if (str != NULL) OPENSSL_free(str); |
632 | if ((ret == 0) && (s != INVALID_SOCKET)) | 637 | if ((ret == 0) && (s != INVALID_SOCKET)) |
633 | { | 638 | { |
634 | closesocket(s); | 639 | closesocket(s); |
@@ -667,7 +672,7 @@ int BIO_accept(int sock, char **addr) | |||
667 | port=ntohs(from.sin_port); | 672 | port=ntohs(from.sin_port); |
668 | if (*addr == NULL) | 673 | if (*addr == NULL) |
669 | { | 674 | { |
670 | if ((p=Malloc(24)) == NULL) | 675 | if ((p=OPENSSL_malloc(24)) == NULL) |
671 | { | 676 | { |
672 | BIOerr(BIO_F_BIO_ACCEPT,ERR_R_MALLOC_FAILURE); | 677 | BIOerr(BIO_F_BIO_ACCEPT,ERR_R_MALLOC_FAILURE); |
673 | goto end; | 678 | goto end; |