From 352c9f9427c0c75a5dd0d8c5b741ae4764eb5fe8 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 2 Jan 2015 21:12:16 -0500 Subject: [PATCH] Don't assume vault strings are null-terminated --- .../Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp index 3f619dbe..7e26599c 100644 --- a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp +++ b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp @@ -425,11 +425,13 @@ template<> static void IRead(const uint8_t*& buf, plString& dest) { uint32_t size = *(reinterpret_cast(buf)); + uint32_t arraySize = size / 2; buf += sizeof(uint32_t); plStringBuffer str; - uint16_t* theStrBuffer = str.CreateWritableBuffer(size / sizeof(uint16_t)); + uint16_t* theStrBuffer = str.CreateWritableBuffer(arraySize - 1); memcpy(theStrBuffer, buf, size); + theStrBuffer[arraySize - 1] = 0; dest = plString::FromUtf16(str); buf += size; }