openresty / lua-resty-string

String utilities and common hash functions for ngx_lua and LuaJIT
429 stars 143 forks source link

Correct aes buffer size #72

Closed miranovy closed 3 years ago

miranovy commented 4 years ago

There was a segmentation fault while decoding because the wrong size buffer was allocated.

I fixed the buffer size according to the documentation https://www.openssl.org/docs/man1.1.0/man3/EVP_EncryptInit.html for encrypt and decrypt.

doujiang24 commented 4 years ago

@miranovy thanks for your contribution, will you help to add a test case for it or a minimal case that we can reproduce it in our side.

miranovy commented 4 years ago

I added small allocation test. The error is not reflected in short texts, but only when decprypting large files on fly when calling EVP_DecryptUpdate repeatedly.