From 0559d8ce2ee83f8a9971e5bc01f732ecb5369f73 Mon Sep 17 00:00:00 2001 From: Zou Yong Date: Fri, 28 Apr 2017 19:33:09 +0800 Subject: [PATCH] Fix decryption failed issue by nonce overwrite If the first packet is less than nonce length, then the chunk nonce data will be overwrote by next packet and result in decrypt failed --- src/stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream.c b/src/stream.c index 5ea30dd4..5d999bb0 100644 --- a/src/stream.c +++ b/src/stream.c @@ -493,7 +493,7 @@ stream_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity) ciphertext->len); if (left_len > 0) { - memcpy(cipher_ctx->chunk->data, ciphertext->data, left_len); + memcpy(cipher_ctx->chunk->data + cipher_ctx->chunk->len, ciphertext->data, left_len); memmove(ciphertext->data, ciphertext->data + left_len, ciphertext->len - left_len); cipher_ctx->chunk->len += left_len;