1
0
forked from mirrors/0ad

Unify duplicate u8* to hex string functions in a new Hexify function variant, similar to bb1f86f515, used by Tests, CacheLoader, Terms and Conditions, Lobby and mod.io.

Removes the call to the sprintf_s function from test_MD5.h in 17718981cf
and JSInterface_Main.cpp in 468d963e78.
As reported by Vladislav that function might not null-terminate strings
on untested/newer platforms, but the caller requires it here.
The sprintf_s calls in other places have the same problem.

Differential Revision: https://code.wildfiregames.com/D1591
Accepted By: Vladislav
This was SVN commit r21863.
This commit is contained in:
elexis
2018-08-08 12:59:05 +00:00
parent 1e59db453a
commit ecce63628c
7 changed files with 34 additions and 36 deletions
+2 -5
View File
@@ -29,6 +29,7 @@
#include "ps/GameSetup/Atlas.h"
#include "ps/Globals.h"
#include "ps/Hotkey.h"
#include "ps/Util.h"
#include "scriptinterface/ScriptInterface.h"
#include "tools/atlas/GameInterface/GameLoop.h"
@@ -118,11 +119,7 @@ std::string JSI_Main::CalculateMD5(ScriptInterface::CxPrivate* UNUSED(pCxPrivate
m.Update((const u8*)input.c_str(), input.length());
m.Final(digest);
char digeststr[MD5::DIGESTSIZE*2+1];
for (size_t i = 0; i < MD5::DIGESTSIZE; ++i)
sprintf_s(digeststr+2*i, 3, "%02x", (unsigned int)digest[i]);
return digeststr;
return Hexify(digest, MD5::DIGESTSIZE);
}
void JSI_Main::RegisterScriptFunctions(const ScriptInterface& scriptInterface)