summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-06-29 18:27:41 +0200
committerMattes D <github@xoft.cz>2014-06-29 18:27:41 +0200
commit3c631fc0f95f383c53d18cd7760ab2e3a8609240 (patch)
treecba973b26f842598e3399aed2992414c24bbe6b9 /src
parentMerge pull request #1136 from Howaner/GlobalFixes (diff)
downloadcuberite-3c631fc0f95f383c53d18cd7760ab2e3a8609240.tar
cuberite-3c631fc0f95f383c53d18cd7760ab2e3a8609240.tar.gz
cuberite-3c631fc0f95f383c53d18cd7760ab2e3a8609240.tar.bz2
cuberite-3c631fc0f95f383c53d18cd7760ab2e3a8609240.tar.lz
cuberite-3c631fc0f95f383c53d18cd7760ab2e3a8609240.tar.xz
cuberite-3c631fc0f95f383c53d18cd7760ab2e3a8609240.tar.zst
cuberite-3c631fc0f95f383c53d18cd7760ab2e3a8609240.zip
Diffstat (limited to '')
-rw-r--r--src/ClientHandle.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index abe9a86f5..662ee7927 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -241,9 +241,11 @@ AString cClientHandle::GenerateOfflineUUID(const AString & a_Username)
// Generate an md5 checksum, and use it as base for the ID:
unsigned char MD5[16];
md5((const unsigned char *)a_Username.c_str(), a_Username.length(), MD5);
+ MD5[6] &= 0x0f; // Need to trim to 4 bits only...
+ MD5[8] &= 0x0f; // ... otherwise %01x overflows into two chars
return Printf("%02x%02x%02x%02x-%02x%02x-3%01x%02x-8%01x%02x-%02x%02x%02x%02x%02x%02x",
- MD5[0], MD5[1], MD5[2], MD5[3],
- MD5[4], MD5[5], MD5[6], MD5[7],
+ MD5[0], MD5[1], MD5[2], MD5[3],
+ MD5[4], MD5[5], MD5[6], MD5[7],
MD5[8], MD5[9], MD5[10], MD5[11],
MD5[12], MD5[13], MD5[14], MD5[15]
);