From 810ccffd9e02f22e15e92e36c1a1a37344329fcd Mon Sep 17 00:00:00 2001 From: Gent Semaj Date: Fri, 6 Sep 2024 11:58:26 -0400 Subject: [PATCH] Fix bad size calculation due to pointer cast --- src/core/CNStructs.hpp | 2 +- src/servers/CNLoginServer.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/CNStructs.hpp b/src/core/CNStructs.hpp index f9c8dd4..539c89f 100644 --- a/src/core/CNStructs.hpp +++ b/src/core/CNStructs.hpp @@ -40,7 +40,7 @@ // wrapper for U16toU8 #define ARRLEN(x) (sizeof(x)/sizeof(*x)) -#define AUTOU8(x) std::string(x, ARRLEN(x)) +#define AUTOU8(x) std::string((char*)x, ARRLEN(x)) #define AUTOU16TOU8(x) U16toU8(x, ARRLEN(x)) // TODO: rewrite U16toU8 & U8toU16 to not use codecvt diff --git a/src/servers/CNLoginServer.cpp b/src/servers/CNLoginServer.cpp index 659050f..8beb9ed 100644 --- a/src/servers/CNLoginServer.cpp +++ b/src/servers/CNLoginServer.cpp @@ -116,11 +116,11 @@ void CNLoginServer::login(CNSocket* sock, CNPacketData* data) { */ if (isCookieAuth) { // username encoded in TEGid raw - userLogin = std::string(AUTOU8((char*)login->szCookie_TEGid).c_str()); + userLogin = std::string(AUTOU8(login->szCookie_TEGid).c_str()); // N.B. clients that use web login without proper cookies // send their passwords in the cookie field - userPassword = std::string(AUTOU8((char*)login->szCookie_authid).c_str()); + userPassword = std::string(AUTOU8(login->szCookie_authid).c_str()); } else { userLogin = std::string(AUTOU16TOU8(login->szID).c_str()); userPassword = std::string(AUTOU16TOU8(login->szPassword).c_str());