user32: Fix a SetClipboardData() buffer overflow.
commit605ecafa67a4e034328b69396581e2f9b60d7af3
authorFrancois Gouget <fgouget@codeweavers.com>
Wed, 21 Dec 2022 17:48:29 +0000 (21 18:48 +0100)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 25 Jan 2023 09:10:24 +0000 (25 10:10 +0100)
tree86cf9aa5b19807743e3c64c86820344df4af6569
parentee4f8cbb2066bf7ff2721fb081c1ab091ed8840e
user32: Fix a SetClipboardData() buffer overflow.

Wine would append a correctly aligned NUL Unicode character to
terminate the string but overflow the buffer by one byte for odd-sized
strings.
Windows instead overwrites the last two buffer bytes with a NUL Unicode
character which ends up being misaligned for odd-sized strings.
The clipboard data has a size field anyway so match the Windows
behavior.
Tweak the tests to show that SetClipboardData() can overwrite half of
the Unicode string's last character.
dlls/user32/clipboard.c
dlls/user32/tests/clipboard.c