summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
authorhrydgard <hrydgard@gmail.com>2009-02-22 11:01:08 +0000
committerhrydgard <hrydgard@gmail.com>2009-02-22 11:01:08 +0000
commit8741026ba094cd00db40ff46b89143b753cf2aa9 (patch)
tree5b5905c18135b5df4fae70b281331005634029f0 /Source/Core/Common
parente5cf9c8b8c591ad977b5700f788dcbea88d3d09b (diff)
fix tiny buffer overflow in Hex2Ascii()
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2361 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/Src/StringUtil.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/Source/Core/Common/Src/StringUtil.cpp b/Source/Core/Common/Src/StringUtil.cpp
index 523ed3133d..1d48efa223 100644
--- a/Source/Core/Common/Src/StringUtil.cpp
+++ b/Source/Core/Common/Src/StringUtil.cpp
@@ -76,7 +76,9 @@ u32 Ascii2Hex(std::string _Text)
u32 Result = 0;
// Max 32-bit values are supported
- int Length = _Text.length(); if (Length > 4) Length = 4;
+ int Length = _Text.length();
+ if (Length > 4)
+ Length = 4;
for (int i = 0; i < Length; i++)
{
@@ -86,11 +88,12 @@ u32 Ascii2Hex(std::string _Text)
// Return the value
return Result;
}
+
// Convert it back again
std::string Hex2Ascii(u32 _Text)
{
// Create temporary storate
- char Result[4];
+ char Result[5]; // need space for the final \0
// Go through the four characters
sprintf(Result, "%c%c%c%c", _Text >> 24, _Text >> 16, _Text >> 8, _Text);
// Return the string