]>
Commit | Line | Data |
---|---|---|
b7ca0ba0 SL |
1 | From 58e334400f719036a246cbc04ad462bb5f9dbea0 Mon Sep 17 00:00:00 2001 |
2 | From: Sasha Levin <sashal@kernel.org> | |
3 | Date: Sun, 4 Feb 2024 16:57:36 +0100 | |
4 | Subject: speakup: Fix 8bit characters from direct synth | |
5 | ||
6 | From: Samuel Thibault <samuel.thibault@ens-lyon.org> | |
7 | ||
8 | [ Upstream commit b6c8dafc9d86eb77e502bb018ec4105e8d2fbf78 ] | |
9 | ||
10 | When userland echoes 8bit characters to /dev/synth with e.g. | |
11 | ||
12 | echo -e '\xe9' > /dev/synth | |
13 | ||
14 | synth_write would get characters beyond 0x7f, and thus negative when | |
15 | char is signed. When given to synth_buffer_add which takes a u16, this | |
16 | would sign-extend and produce a U+ffxy character rather than U+xy. | |
17 | Users thus get garbled text instead of accents in their output. | |
18 | ||
19 | Let's fix this by making sure that we read unsigned characters. | |
20 | ||
21 | Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> | |
22 | Fixes: 89fc2ae80bb1 ("speakup: extend synth buffer to 16bit unicode characters") | |
23 | Cc: stable@vger.kernel.org | |
24 | Link: https://lore.kernel.org/r/20240204155736.2oh4ot7tiaa2wpbh@begin | |
25 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
26 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
27 | --- | |
28 | drivers/accessibility/speakup/synth.c | 4 +++- | |
29 | 1 file changed, 3 insertions(+), 1 deletion(-) | |
30 | ||
31 | diff --git a/drivers/accessibility/speakup/synth.c b/drivers/accessibility/speakup/synth.c | |
32 | index 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 | -- | |
48 | 2.43.0 | |
49 |