diff options
author | miod <> | 2014-07-10 21:57:40 +0000 |
---|---|---|
committer | miod <> | 2014-07-10 21:57:40 +0000 |
commit | b72cc7a509b05335b9f244d5b7a6a12a03c0bd7f (patch) | |
tree | b3bf760955fe99d2f97e8c9c8c14de047b5eed2c | |
parent | 94198e09d9771b3cedf7f26bbdecb991acb691c3 (diff) | |
download | openbsd-b72cc7a509b05335b9f244d5b7a6a12a03c0bd7f.tar.gz openbsd-b72cc7a509b05335b9f244d5b7a6a12a03c0bd7f.tar.bz2 openbsd-b72cc7a509b05335b9f244d5b7a6a12a03c0bd7f.zip |
Simplify realloc() usage; ok tedu@
-rw-r--r-- | src/lib/libcrypto/bio/b_sock.c | 21 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bio/b_sock.c | 21 |
2 files changed, 12 insertions, 30 deletions
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index 32ac3b0664..bbae2a31b9 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.52 2014/07/10 13:58:22 jsing Exp $ */ | 1 | /* $OpenBSD: b_sock.c,v 1.53 2014/07/10 21:57:40 miod 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 | * |
@@ -417,26 +417,17 @@ BIO_accept(int sock, char **addr) | |||
417 | break; | 417 | break; |
418 | nl = strlen(h) + strlen(s) + 2; | 418 | nl = strlen(h) + strlen(s) + 2; |
419 | p = *addr; | 419 | p = *addr; |
420 | if (p) { | 420 | if (p) |
421 | *p = '\0'; | 421 | *p = '\0'; |
422 | if (!(tmp = realloc(p, nl))) { | 422 | if (!(tmp = realloc(p, nl))) { |
423 | close(ret); | ||
424 | ret = -1; | ||
425 | free(p); | ||
426 | *addr = NULL; | ||
427 | BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE); | ||
428 | goto end; | ||
429 | } | ||
430 | p = tmp; | ||
431 | } else { | ||
432 | p = malloc(nl); | ||
433 | } | ||
434 | if (p == NULL) { | ||
435 | close(ret); | 423 | close(ret); |
436 | ret = -1; | 424 | ret = -1; |
425 | free(p); | ||
426 | *addr = NULL; | ||
437 | BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE); | 427 | BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE); |
438 | goto end; | 428 | goto end; |
439 | } | 429 | } |
430 | p = tmp; | ||
440 | *addr = p; | 431 | *addr = p; |
441 | snprintf(*addr, nl, "%s:%s", h, s); | 432 | snprintf(*addr, nl, "%s:%s", h, s); |
442 | goto end; | 433 | goto end; |
diff --git a/src/lib/libssl/src/crypto/bio/b_sock.c b/src/lib/libssl/src/crypto/bio/b_sock.c index 32ac3b0664..bbae2a31b9 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.52 2014/07/10 13:58:22 jsing Exp $ */ | 1 | /* $OpenBSD: b_sock.c,v 1.53 2014/07/10 21:57:40 miod 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 | * |
@@ -417,26 +417,17 @@ BIO_accept(int sock, char **addr) | |||
417 | break; | 417 | break; |
418 | nl = strlen(h) + strlen(s) + 2; | 418 | nl = strlen(h) + strlen(s) + 2; |
419 | p = *addr; | 419 | p = *addr; |
420 | if (p) { | 420 | if (p) |
421 | *p = '\0'; | 421 | *p = '\0'; |
422 | if (!(tmp = realloc(p, nl))) { | 422 | if (!(tmp = realloc(p, nl))) { |
423 | close(ret); | ||
424 | ret = -1; | ||
425 | free(p); | ||
426 | *addr = NULL; | ||
427 | BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE); | ||
428 | goto end; | ||
429 | } | ||
430 | p = tmp; | ||
431 | } else { | ||
432 | p = malloc(nl); | ||
433 | } | ||
434 | if (p == NULL) { | ||
435 | close(ret); | 423 | close(ret); |
436 | ret = -1; | 424 | ret = -1; |
425 | free(p); | ||
426 | *addr = NULL; | ||
437 | BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE); | 427 | BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE); |
438 | goto end; | 428 | goto end; |
439 | } | 429 | } |
430 | p = tmp; | ||
440 | *addr = p; | 431 | *addr = p; |
441 | snprintf(*addr, nl, "%s:%s", h, s); | 432 | snprintf(*addr, nl, "%s:%s", h, s); |
442 | goto end; | 433 | goto end; |