From 4b719df371f5697c7ca88266d3b8691c0decfe30 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 10 Jan 2022 10:55:48 +0100 Subject: [PATCH] Fixed #7521: Ensure '\0' termination of clipboard strings --- uwac/libuwac/uwac-clipboard.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/uwac/libuwac/uwac-clipboard.c b/uwac/libuwac/uwac-clipboard.c index f61379d1a..9fb3d9acb 100644 --- a/uwac/libuwac/uwac-clipboard.c +++ b/uwac/libuwac/uwac-clipboard.c @@ -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]); - *size = pos + 1; + if (alloc > 0) + { + data[pos] = '\0'; + *size = pos + 1; + } return data; }