mirror of
https://github.com/MariaDB/server.git
synced 2025-08-05 13:16:09 +03:00
MDEV-30389 Ensure correct dlen during encryption
This patch ensures that all direct and indirect calls to encryption_crypt provide a `dlen` value correctly initialized to the destination buffer length, allowing encryption plugins to verify available space. It also adds assertions to verify related invariants. Signed-off-by: Trevor Gross <tmgross@umich.edu>
This commit is contained in:
committed by
Sergei Golubchik
parent
01e9e3955a
commit
b91d5bcedc
@@ -57,10 +57,13 @@ static inline int encryption_crypt(const unsigned char* src, unsigned int slen,
|
||||
{
|
||||
void *ctx= alloca(encryption_handler.encryption_ctx_size_func((key_id),(key_version)));
|
||||
int res1, res2;
|
||||
unsigned int d1, d2;
|
||||
unsigned int d1, d2= *dlen;
|
||||
assert(*dlen >= slen);
|
||||
assert((dst[*dlen - 1]= 1));
|
||||
if ((res1= encryption_handler.encryption_ctx_init_func((ctx),(key),(klen),(iv),(ivlen),(flags),(key_id),(key_version))))
|
||||
return res1;
|
||||
res1= encryption_handler.encryption_ctx_update_func((ctx),(src),(slen),(dst),(&d1));
|
||||
d2-= d1;
|
||||
res2= encryption_handler.encryption_ctx_finish_func((ctx),(dst + d1),(&d2));
|
||||
*dlen= d1 + d2;
|
||||
return res1 ? res1 : res2;
|
||||
|
Reference in New Issue
Block a user