Fixed #7521: Ensure '\0' termination of clipboard strings

This commit is contained in:
Armin Novak 2022-01-10 10:55:48 +01:00 committed by akallabeth
parent 599bc18f33
commit 4b719df371
1 changed files with 6 additions and 2 deletions

View File

@ -153,7 +153,6 @@ UwacReturnCode UwacSeatRegisterClipboard(UwacSeat* s)
if (rc != UWAC_SUCCESS)
return rc;
event = (UwacClipboardEvent*)UwacDisplayNewEvent(s->display, UWAC_EVENT_CLIPBOARD_AVAILABLE);
if (!event)
@ -237,6 +236,7 @@ void* UwacClipboardDataGet(UwacSeat* seat, const char* mime, size_t* size)
if (!seat || !mime || !size || !seat->offer)
return NULL;
*size = 0;
if (pipe(pipefd) != 0)
return NULL;
@ -272,6 +272,10 @@ void* UwacClipboardDataGet(UwacSeat* seat, const char* mime, size_t* size)
close(pipefd[0]);
close(pipefd[1]);
if (alloc > 0)
{
data[pos] = '\0';
*size = pos + 1;
}
return data;
}