[winpr,clipboard] fix file list conversion

This commit is contained in:
Armin Novak 2023-02-21 14:47:20 +01:00 committed by akallabeth
parent fe3de9b9bf
commit 3d3e577190

View File

@ -917,9 +917,16 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32
const size_t endlen = strlen(lineending); const size_t endlen = strlen(lineending);
if (alloc > endlen) if (alloc > endlen)
{ {
if (memcmp(&dst[alloc - endlen - 1], lineending, endlen) == 0) const size_t len = strnlen(dst, alloc);
if (len < endlen)
{ {
memset(&dst[alloc - endlen - 1], 0, endlen); free(dst);
return NULL;
}
if (memcmp(&dst[len - endlen], lineending, endlen) == 0)
{
memset(&dst[len - endlen], 0, endlen);
alloc -= endlen; alloc -= endlen;
} }
} }
@ -939,8 +946,8 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32
static void* convert_filedescriptors_to_uri_list(wClipboard* clipboard, UINT32 formatId, static void* convert_filedescriptors_to_uri_list(wClipboard* clipboard, UINT32 formatId,
const void* data, UINT32* pSize) const void* data, UINT32* pSize)
{ {
return convert_filedescriptors_to_file_list(clipboard, formatId, data, pSize, "", return convert_filedescriptors_to_file_list(clipboard, formatId, data, pSize, "", "file://",
"file:", "\r\n", FALSE); "\r\n", FALSE);
} }
/* Prepend header of common gnome format to file list*/ /* Prepend header of common gnome format to file list*/