From 5179ccd59657b9673855139f9c6b8e244386decb Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Thu, 26 Jun 2014 16:38:36 +0300 Subject: [PATCH] Fixed encryption in srvconf.lib --- stglibs/srvconf.lib/netunit.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stglibs/srvconf.lib/netunit.cpp b/stglibs/srvconf.lib/netunit.cpp index 43428530..596f766f 100644 --- a/stglibs/srvconf.lib/netunit.cpp +++ b/stglibs/srvconf.lib/netunit.cpp @@ -293,7 +293,7 @@ int ret; memset(loginZ, 0, ADM_LOGIN_LEN); BLOWFISH_CTX ctx; InitContext(password.c_str(), PASSWD_LEN, &ctx); -EncryptString(loginZ, login.c_str(), std::min(login.length(), ADM_LOGIN_LEN), &ctx); +EncryptString(loginZ, login.c_str(), std::min(login.length() + 1, ADM_LOGIN_LEN), &ctx); if (send(outerSocket, loginZ, ADM_LOGIN_LEN, 0) <= 0) { errorMsg = SEND_LOGIN_ERROR; @@ -345,9 +345,9 @@ int r = strlen(text) % ENC_MSG_LEN; BLOWFISH_CTX ctx; InitContext(password.c_str(), PASSWD_LEN, &ctx); -char buffer[text.length()]; -EncryptString(buffer, text.c_str(), text.length(), &ctx); -if (send(outerSocket, buffer, text.length(), 0) <= 0) +char buffer[text.length() + 9]; +EncryptString(buffer, text.c_str(), text.length() + 1, &ctx); +if (send(outerSocket, buffer, sizeof(buffer), 0) <= 0) { errorMsg = SEND_DATA_ERROR; return st_send_fail; -- 2.44.2