diff options
| author | tedu <> | 2016-05-04 14:53:29 +0000 |
|---|---|---|
| committer | tedu <> | 2016-05-04 14:53:29 +0000 |
| commit | 519d297fc2fe7aa90db3d99be37ea38e11547106 (patch) | |
| tree | f6ce35162dc70237060be00178eb4181cce7e457 /src/lib/libcrypto/evp/encode.c | |
| parent | da87549cff83dd705f62d49b47eeff6fcc5b6f4e (diff) | |
| download | openbsd-519d297fc2fe7aa90db3d99be37ea38e11547106.tar.gz openbsd-519d297fc2fe7aa90db3d99be37ea38e11547106.tar.bz2 openbsd-519d297fc2fe7aa90db3d99be37ea38e11547106.zip | |
revert the big change from yesterday to prepare for smaller commits.
Diffstat (limited to 'src/lib/libcrypto/evp/encode.c')
| -rw-r--r-- | src/lib/libcrypto/evp/encode.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/lib/libcrypto/evp/encode.c b/src/lib/libcrypto/evp/encode.c index e4104173d4..637870cef6 100644 --- a/src/lib/libcrypto/evp/encode.c +++ b/src/lib/libcrypto/evp/encode.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: encode.c,v 1.22 2016/05/03 14:05:41 bcook Exp $ */ | 1 | /* $OpenBSD: encode.c,v 1.23 2016/05/04 14:53:29 tedu 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 | * |
| @@ -125,13 +125,13 @@ EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, | |||
| 125 | const unsigned char *in, int inl) | 125 | const unsigned char *in, int inl) |
| 126 | { | 126 | { |
| 127 | int i, j; | 127 | int i, j; |
| 128 | size_t total = 0; | 128 | unsigned int total = 0; |
| 129 | 129 | ||
| 130 | *outl = 0; | 130 | *outl = 0; |
| 131 | if (inl == 0) | 131 | if (inl == 0) |
| 132 | return; | 132 | return; |
| 133 | OPENSSL_assert(ctx->length <= (int)sizeof(ctx->enc_data)); | 133 | OPENSSL_assert(ctx->length <= (int)sizeof(ctx->enc_data)); |
| 134 | if (ctx->length - ctx->num > inl) { | 134 | if ((ctx->num + inl) < ctx->length) { |
| 135 | memcpy(&(ctx->enc_data[ctx->num]), in, inl); | 135 | memcpy(&(ctx->enc_data[ctx->num]), in, inl); |
| 136 | ctx->num += inl; | 136 | ctx->num += inl; |
| 137 | return; | 137 | return; |
| @@ -148,7 +148,7 @@ EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, | |||
| 148 | *out = '\0'; | 148 | *out = '\0'; |
| 149 | total = j + 1; | 149 | total = j + 1; |
| 150 | } | 150 | } |
| 151 | while (inl >= ctx->length && total <= INT_MAX) { | 151 | while (inl >= ctx->length) { |
| 152 | j = EVP_EncodeBlock(out, in, ctx->length); | 152 | j = EVP_EncodeBlock(out, in, ctx->length); |
| 153 | in += ctx->length; | 153 | in += ctx->length; |
| 154 | inl -= ctx->length; | 154 | inl -= ctx->length; |
| @@ -157,11 +157,6 @@ EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, | |||
| 157 | *out = '\0'; | 157 | *out = '\0'; |
| 158 | total += j + 1; | 158 | total += j + 1; |
| 159 | } | 159 | } |
| 160 | if (total > INT_MAX) { | ||
| 161 | /* Too much output data! */ | ||
| 162 | *outl = 0; | ||
| 163 | return; | ||
| 164 | } | ||
| 165 | if (inl != 0) | 160 | if (inl != 0) |
| 166 | memcpy(&(ctx->enc_data[0]), in, inl); | 161 | memcpy(&(ctx->enc_data[0]), in, inl); |
| 167 | ctx->num = inl; | 162 | ctx->num = inl; |
