Fix #106040: pasting long text fails in Gnome-Shell/Wayland
Workaround gnome-shell including uninitialized memory when pasting from the clipboard. Where `read` woud Reading from the pipe into a power-of-two buffer works around the problem. It's not clear why this only impacts gnome-shell - as there is no significant down-side to changing the buffer size, apply a workaround.
This commit is contained in:
@@ -2016,7 +2016,13 @@ static char *read_file_as_buffer(const int fd, const bool nil_terminate, size_t
|
||||
{
|
||||
struct ByteChunk {
|
||||
ByteChunk *next;
|
||||
char data[4096 - sizeof(ByteChunk *)];
|
||||
/* NOTE(@ideasman42): On GNOME-SHELL-43.3, non powers of two values
|
||||
* (1023 or 4088 for e.g.) makes `read()` return longer values than are actually read
|
||||
* (causing uninitialized memory to be used) as well as truncating the end of the buffer.
|
||||
* The WAYLAND spec doesn't mention buffer-size so this may be a bug in GNOME-SHELL.
|
||||
* Whatever the case, using a power of two isn't a problem (besides some slop-space waste).
|
||||
* This works in KDE & WLROOTS based compositors, see: #106040. */
|
||||
char data[4096];
|
||||
};
|
||||
ByteChunk *chunk_first = nullptr, **chunk_link_p = &chunk_first;
|
||||
bool ok = true;
|
||||
|
||||
Reference in New Issue
Block a user