From a1c3c1ad64c75e952eff7975036e2f9e25fa9ca3 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 2 May 2018 09:21:42 +0200 Subject: [PATCH] Added proper return value checks for clipboard data. --- client/X11/xf_cliprdr.c | 8 ++++++++ winpr/libwinpr/clipboard/clipboard.c | 1 + 2 files changed, 9 insertions(+) diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index e141e196d..392f9d135 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -1422,6 +1422,14 @@ static UINT xf_cliprdr_server_format_data_response(CliprdrClientContext* DstSize = 0; pDstData = (BYTE*) ClipboardGetData(clipboard->system, dstFormatId, &DstSize); + if (!pDstData) + { + WLog_ERR(TAG, "failed to get clipboard data in format %s [source format %s]", + ClipboardGetFormatName(clipboard, dstFormatId), + ClipboardGetFormatName(clipboard, srcFormatId)); + return ERROR_INTERNAL_ERROR; + } + if (nullTerminated) { while (DstSize > 0 && pDstData[DstSize - 1] == '\0') diff --git a/winpr/libwinpr/clipboard/clipboard.c b/winpr/libwinpr/clipboard/clipboard.c index 35956b8bc..3d945bcd5 100644 --- a/winpr/libwinpr/clipboard/clipboard.c +++ b/winpr/libwinpr/clipboard/clipboard.c @@ -436,6 +436,7 @@ void* ClipboardGetData(wClipboard* clipboard, UINT32 formatId, UINT32* pSize) if (!pSize) return NULL; + *pSize = 0; format = ClipboardFindFormat(clipboard, clipboard->formatId, NULL); if (!format)