diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/buffer/buffer.c | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/src/lib/libcrypto/buffer/buffer.c b/src/lib/libcrypto/buffer/buffer.c index 2e4959a58d..f15b93d26c 100644 --- a/src/lib/libcrypto/buffer/buffer.c +++ b/src/lib/libcrypto/buffer/buffer.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: buffer.c,v 1.24 2017/03/16 13:29:56 jsing Exp $ */ | 1 | /* $OpenBSD: buffer.c,v 1.25 2017/04/09 15:03: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 | * |
| @@ -97,33 +97,7 @@ BUF_MEM_free(BUF_MEM *a) | |||
| 97 | int | 97 | int |
| 98 | BUF_MEM_grow(BUF_MEM *str, size_t len) | 98 | BUF_MEM_grow(BUF_MEM *str, size_t len) |
| 99 | { | 99 | { |
| 100 | char *ret; | 100 | return BUF_MEM_grow_clean(str, len); |
| 101 | size_t n; | ||
| 102 | |||
| 103 | if (str->length >= len) { | ||
| 104 | str->length = len; | ||
| 105 | return (len); | ||
| 106 | } | ||
| 107 | if (str->max >= len) { | ||
| 108 | str->length = len; | ||
| 109 | return (len); | ||
| 110 | } | ||
| 111 | /* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */ | ||
| 112 | if (len > LIMIT_BEFORE_EXPANSION) { | ||
| 113 | BUFerror(ERR_R_MALLOC_FAILURE); | ||
| 114 | return 0; | ||
| 115 | } | ||
| 116 | n = (len + 3) / 3 * 4; | ||
| 117 | ret = recallocarray(str->data, str->max, n, 1); | ||
| 118 | if (ret == NULL) { | ||
| 119 | BUFerror(ERR_R_MALLOC_FAILURE); | ||
| 120 | len = 0; | ||
| 121 | } else { | ||
| 122 | str->data = ret; | ||
| 123 | str->max = n; | ||
| 124 | str->length = len; | ||
| 125 | } | ||
| 126 | return (len); | ||
| 127 | } | 101 | } |
| 128 | 102 | ||
| 129 | int | 103 | int |
