mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-11-03 00:13:42 +00:00
Merge pull request #3023 from shadowsocks/fix/aead-decrypt-chunk-compaction
Fix unbounded buffer growth in aead_decrypt chunk reassembly
This commit is contained in:
+6
-3
@@ -650,9 +650,12 @@ aead_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity)
|
||||
chunk->idx = 0;
|
||||
ciphertext->len = 0;
|
||||
} else {
|
||||
brealloc(chunk,
|
||||
chunk->idx + chunk->len + ciphertext->len, capacity);
|
||||
memcpy(chunk->data + chunk->idx + chunk->len,
|
||||
if (chunk->idx > 0) {
|
||||
memmove(chunk->data, chunk->data + chunk->idx, chunk->len);
|
||||
chunk->idx = 0;
|
||||
}
|
||||
brealloc(chunk, chunk->len + ciphertext->len, capacity);
|
||||
memcpy(chunk->data + chunk->len,
|
||||
ciphertext->data, ciphertext->len);
|
||||
chunk->len += ciphertext->len;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user