diff options
author | 2018-08-24 19:45:11 +0000 | |
---|---|---|
committer | 2018-08-24 19:45:11 +0000 | |
commit | 5462a49fa240b57d81c958f52bfb3e45fbe4a387 (patch) | |
tree | a273a4723ca426d373dc6c4d3d5ae3b0a8568ffc /lib/libcrypto/evp/encode.c | |
parent | Provide EVP_CIPHER_CTX_encrypting(). (diff) | |
download | wireguard-openbsd-5462a49fa240b57d81c958f52bfb3e45fbe4a387.tar.xz wireguard-openbsd-5462a49fa240b57d81c958f52bfb3e45fbe4a387.zip |
Convert EVP_EncodeUpdate() to return an int to allow for error
checking. Matches our documented behavior.
Based on OpenSSL commit c5ebfcab713a82a1d46a51c8c2668c419425b387
tested in a bulk by sthen
ok jsing
Diffstat (limited to 'lib/libcrypto/evp/encode.c')
-rw-r--r-- | lib/libcrypto/evp/encode.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/libcrypto/evp/encode.c b/lib/libcrypto/evp/encode.c index 1097a7c9039..07cfd7f2bc4 100644 --- a/lib/libcrypto/evp/encode.c +++ b/lib/libcrypto/evp/encode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: encode.c,v 1.24 2016/05/04 15:05:13 tedu Exp $ */ +/* $OpenBSD: encode.c,v 1.25 2018/08/24 19:45:11 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -120,7 +120,7 @@ EVP_EncodeInit(EVP_ENCODE_CTX *ctx) ctx->line_num = 0; } -void +int EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl) { @@ -128,13 +128,13 @@ EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, size_t total = 0; *outl = 0; - if (inl == 0) - return; + if (inl <= 0) + return 0; OPENSSL_assert(ctx->length <= (int)sizeof(ctx->enc_data)); if (ctx->length - ctx->num > inl) { memcpy(&(ctx->enc_data[ctx->num]), in, inl); ctx->num += inl; - return; + return 1; } if (ctx->num != 0) { i = ctx->length - ctx->num; @@ -160,12 +160,14 @@ EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, if (total > INT_MAX) { /* Too much output data! */ *outl = 0; - return; + return 0; } if (inl != 0) memcpy(&(ctx->enc_data[0]), in, inl); ctx->num = inl; *outl = total; + + return 1; } void |