From 7b8931292318c145ce34ec53d4ee8f6a3291274e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 5 Apr 2015 11:52:57 +0300 Subject: [PATCH] Fixed potential issue with read beyond buffer boundaries --- src/posix/i_system.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/posix/i_system.cpp b/src/posix/i_system.cpp index f87cf76ae1..0a1b2f69a1 100644 --- a/src/posix/i_system.cpp +++ b/src/posix/i_system.cpp @@ -699,7 +699,12 @@ FString I_GetFromClipboard (bool use_primary_selection) if (CFDataRef data = GetPasteboardData(itemID, kUTTypeUTF8PlainText)) { - result = reinterpret_cast(CFDataGetBytePtr(data)); + const CFIndex bufferLength = CFDataGetLength(data); + char* const buffer = result.LockNewBuffer(bufferLength); + + memcpy(buffer, CFDataGetBytePtr(data), bufferLength); + + result.UnlockBuffer(); } else if (CFDataRef data = GetPasteboardData(itemID, kUTTypeUTF16PlainText)) {