diff options
author | jsing <> | 2020-03-12 17:15:33 +0000 |
---|---|---|
committer | jsing <> | 2020-03-12 17:15:33 +0000 |
commit | 755b6e0d6d04ef513897a809271a846b984da4e8 (patch) | |
tree | f3e6b992fd31985d20dc9824ea049c8329f758fd /src/lib/libssl/ssl_both.c | |
parent | 8a5e591492888ac3f5e804aaef546ffe93f39818 (diff) | |
download | openbsd-755b6e0d6d04ef513897a809271a846b984da4e8.tar.gz openbsd-755b6e0d6d04ef513897a809271a846b984da4e8.tar.bz2 openbsd-755b6e0d6d04ef513897a809271a846b984da4e8.zip |
Use calloc() rather than malloc() when allocating buffers.
This reduces the chance of accidently leaking stack memory.
ok inoguchi@ tb@
Diffstat (limited to 'src/lib/libssl/ssl_both.c')
-rw-r--r-- | src/lib/libssl/ssl_both.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libssl/ssl_both.c b/src/lib/libssl/ssl_both.c index 8ec94542c2..b8929d8f84 100644 --- a/src/lib/libssl/ssl_both.c +++ b/src/lib/libssl/ssl_both.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_both.c,v 1.16 2020/01/23 10:48:37 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_both.c,v 1.17 2020/03/12 17:15:33 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 | * |
@@ -702,7 +702,7 @@ ssl3_setup_read_buffer(SSL *s) | |||
702 | if (S3I(s)->rbuf.buf == NULL) { | 702 | if (S3I(s)->rbuf.buf == NULL) { |
703 | len = SSL3_RT_MAX_PLAIN_LENGTH + | 703 | len = SSL3_RT_MAX_PLAIN_LENGTH + |
704 | SSL3_RT_MAX_ENCRYPTED_OVERHEAD + headerlen + align; | 704 | SSL3_RT_MAX_ENCRYPTED_OVERHEAD + headerlen + align; |
705 | if ((p = malloc(len)) == NULL) | 705 | if ((p = calloc(1, len)) == NULL) |
706 | goto err; | 706 | goto err; |
707 | S3I(s)->rbuf.buf = p; | 707 | S3I(s)->rbuf.buf = p; |
708 | S3I(s)->rbuf.len = len; | 708 | S3I(s)->rbuf.len = len; |
@@ -736,7 +736,7 @@ ssl3_setup_write_buffer(SSL *s) | |||
736 | len += headerlen + align + | 736 | len += headerlen + align + |
737 | SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD; | 737 | SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD; |
738 | 738 | ||
739 | if ((p = malloc(len)) == NULL) | 739 | if ((p = calloc(1, len)) == NULL) |
740 | goto err; | 740 | goto err; |
741 | S3I(s)->wbuf.buf = p; | 741 | S3I(s)->wbuf.buf = p; |
742 | S3I(s)->wbuf.len = len; | 742 | S3I(s)->wbuf.len = len; |