summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorSusan LoVerso <sue@wiredtiger.com>2015-04-27 15:35:15 -0400
committerSusan LoVerso <sue@wiredtiger.com>2015-04-27 15:35:15 -0400
commit6b104ea42d173e0fca8d29669fb10122e9f1a03c (patch)
tree8934a99bea2e41a9088075c4f5d4c421cc28fe0f /ext
parenta4d8ba982ee4559fe02210532cce429aec111d76 (diff)
downloadmongo-6b104ea42d173e0fca8d29669fb10122e9f1a03c.tar.gz
Use result_len to allow for padding. Send in the buffer size as
dst_len. WT-1822
Diffstat (limited to 'ext')
-rw-r--r--ext/encryptors/rotn/rotn_encrypt.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/encryptors/rotn/rotn_encrypt.c b/ext/encryptors/rotn/rotn_encrypt.c
index 631004513e6..22595419d56 100644
--- a/ext/encryptors/rotn/rotn_encrypt.c
+++ b/ext/encryptors/rotn/rotn_encrypt.c
@@ -213,6 +213,7 @@ rotn_decrypt(WT_ENCRYPTOR *encryptor, WT_SESSION *session,
size_t *result_lenp)
{
ROTN_ENCRYPTOR *rotn_encryptor = (ROTN_ENCRYPTOR *)encryptor;
+ size_t mylen;
uint32_t i;
(void)session; /* Unused */
@@ -222,7 +223,8 @@ rotn_decrypt(WT_ENCRYPTOR *encryptor, WT_SESSION *session,
/*
* Make sure it is big enough.
*/
- if (dst_len < src_len - CHKSUM_LEN - IV_LEN) {
+ mylen = src_len - CHKSUM_LEN - IV_LEN;
+ if (dst_len < mylen) {
fprintf(stderr, "Rotate: ENOMEM ERROR\n");
return (ENOMEM);
}
@@ -235,7 +237,7 @@ rotn_decrypt(WT_ENCRYPTOR *encryptor, WT_SESSION *session,
* decrypt the destination buffer.
*/
i = CHKSUM_LEN + IV_LEN;
- memcpy(&dst[0], &src[i], dst_len);
+ memcpy(&dst[0], &src[i], mylen);
/*
* Depending on whether we have a secret key or not,
* call the common rotate or shift function on the text portion
@@ -246,11 +248,11 @@ rotn_decrypt(WT_ENCRYPTOR *encryptor, WT_SESSION *session,
* !!! Most implementations would need the IV too.
*/
if (rotn_encryptor->shift_len == 0)
- do_rotate(&dst[0], dst_len, 26 - rotn_encryptor->rot_N);
+ do_rotate(&dst[0], mylen, 26 - rotn_encryptor->rot_N);
else
- do_shift(&dst[0], dst_len,
+ do_shift(&dst[0], mylen,
rotn_encryptor->shift_back, rotn_encryptor->shift_len);
- *result_lenp = dst_len;
+ *result_lenp = mylen;
return (0);
}
/*! [WT_ENCRYPTOR decrypt] */