From 951028fed36c4e1faeb298deaa648e407145b164 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 19 Aug 2009 16:28:23 -0700 Subject: [PATCH] auth: fix aes encryption --- src/auth/CryptoTools.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/auth/CryptoTools.cc b/src/auth/CryptoTools.cc index 294407baba80f..83bb5a1e50f4a 100644 --- a/src/auth/CryptoTools.cc +++ b/src/auth/CryptoTools.cc @@ -72,7 +72,8 @@ bool CryptoAES::encrypt(EntitySecret& secret, bufferlist& in, bufferlist& out) const unsigned char *in_buf = (const unsigned char *)in.c_str(); int outlen = (in_len + AES_BLOCK_SIZE) & ~(AES_BLOCK_SIZE -1); int tmplen; - unsigned char outbuf[outlen]; +#define OUT_BUF_EXTRA 128 + unsigned char outbuf[outlen + OUT_BUF_EXTRA]; if (sec_bl.length() < AES_KEY_LEN) { derr(0) << "key is too short" << dendl; @@ -92,7 +93,7 @@ bool CryptoAES::encrypt(EntitySecret& secret, bufferlist& in, bufferlist& out) return false; } - out.append((const char *)outbuf, outlen); + out.append((const char *)outbuf, outlen + tmplen); return true; } -- 2.39.5