]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-5.10/speakup-fix-8bit-characters-from-direct-synth.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / queue-5.10 / speakup-fix-8bit-characters-from-direct-synth.patch
CommitLineData
b7ca0ba0
SL
1From 58e334400f719036a246cbc04ad462bb5f9dbea0 Mon Sep 17 00:00:00 2001
2From: Sasha Levin <sashal@kernel.org>
3Date: Sun, 4 Feb 2024 16:57:36 +0100
4Subject: speakup: Fix 8bit characters from direct synth
5
6From: Samuel Thibault <samuel.thibault@ens-lyon.org>
7
8[ Upstream commit b6c8dafc9d86eb77e502bb018ec4105e8d2fbf78 ]
9
10When userland echoes 8bit characters to /dev/synth with e.g.
11
12echo -e '\xe9' > /dev/synth
13
14synth_write would get characters beyond 0x7f, and thus negative when
15char is signed. When given to synth_buffer_add which takes a u16, this
16would sign-extend and produce a U+ffxy character rather than U+xy.
17Users thus get garbled text instead of accents in their output.
18
19Let's fix this by making sure that we read unsigned characters.
20
21Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
22Fixes: 89fc2ae80bb1 ("speakup: extend synth buffer to 16bit unicode characters")
23Cc: stable@vger.kernel.org
24Link: https://lore.kernel.org/r/20240204155736.2oh4ot7tiaa2wpbh@begin
25Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26Signed-off-by: Sasha Levin <sashal@kernel.org>
27---
28 drivers/accessibility/speakup/synth.c | 4 +++-
29 1 file changed, 3 insertions(+), 1 deletion(-)
30
31diff --git a/drivers/accessibility/speakup/synth.c b/drivers/accessibility/speakup/synth.c
32index ac47dbac72075..82cfc5ec6bdf9 100644
33--- a/drivers/accessibility/speakup/synth.c
34+++ b/drivers/accessibility/speakup/synth.c
35@@ -208,8 +208,10 @@ void spk_do_flush(void)
36 wake_up_process(speakup_task);
37 }
38
39-void synth_write(const char *buf, size_t count)
40+void synth_write(const char *_buf, size_t count)
41 {
42+ const unsigned char *buf = (const unsigned char *) _buf;
43+
44 while (count--)
45 synth_buffer_add(*buf++);
46 synth_start();
47--
482.43.0
49