summaryrefslogtreecommitdiffstats
path: root/crypto/openssl/crypto/bio/b_print.c
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2015-06-11 19:07:45 +0000
committerjkim <jkim@FreeBSD.org>2015-06-11 19:07:45 +0000
commit5c266cb7c932e78233437385fe6993499ad9e2ea (patch)
treefb5b3a19a5d9e924a0f43b0ef4999a09e22aa1b4 /crypto/openssl/crypto/bio/b_print.c
parent3a6c5b791fafa79766a5c99c288a7d1ef495157a (diff)
downloadFreeBSD-src-5c266cb7c932e78233437385fe6993499ad9e2ea.zip
FreeBSD-src-5c266cb7c932e78233437385fe6993499ad9e2ea.tar.gz
MFC: r284283
Merge OpenSSL 1.0.1n.
Diffstat (limited to 'crypto/openssl/crypto/bio/b_print.c')
-rw-r--r--crypto/openssl/crypto/bio/b_print.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/crypto/openssl/crypto/bio/b_print.c b/crypto/openssl/crypto/bio/b_print.c
index c2cf6e6..7c81e25 100644
--- a/crypto/openssl/crypto/bio/b_print.c
+++ b/crypto/openssl/crypto/bio/b_print.c
@@ -704,32 +704,29 @@ doapr_outch(char **sbuffer,
/* If we haven't at least one buffer, someone has doe a big booboo */
assert(*sbuffer != NULL || buffer != NULL);
- if (buffer) {
- while (*currlen >= *maxlen) {
- if (*buffer == NULL) {
- if (*maxlen == 0)
- *maxlen = 1024;
- *buffer = OPENSSL_malloc(*maxlen);
- if(!*buffer) {
- /* Panic! Can't really do anything sensible. Just return */
- return;
- }
- if (*currlen > 0) {
- assert(*sbuffer != NULL);
- memcpy(*buffer, *sbuffer, *currlen);
- }
- *sbuffer = NULL;
- } else {
- *maxlen += 1024;
- *buffer = OPENSSL_realloc(*buffer, *maxlen);
- if(!*buffer) {
- /* Panic! Can't really do anything sensible. Just return */
- return;
- }
+ /* |currlen| must always be <= |*maxlen| */
+ assert(*currlen <= *maxlen);
+
+ if (buffer && *currlen == *maxlen) {
+ *maxlen += 1024;
+ if (*buffer == NULL) {
+ *buffer = OPENSSL_malloc(*maxlen);
+ if (!*buffer) {
+ /* Panic! Can't really do anything sensible. Just return */
+ return;
+ }
+ if (*currlen > 0) {
+ assert(*sbuffer != NULL);
+ memcpy(*buffer, *sbuffer, *currlen);
+ }
+ *sbuffer = NULL;
+ } else {
+ *buffer = OPENSSL_realloc(*buffer, *maxlen);
+ if (!*buffer) {
+ /* Panic! Can't really do anything sensible. Just return */
+ return;
}
}
- /* What to do if *buffer is NULL? */
- assert(*sbuffer != NULL || *buffer != NULL);
}
if (*currlen < *maxlen) {
OpenPOWER on IntegriCloud