Commit b6c8dafc authored by Samuel Thibault's avatar Samuel Thibault Committed by Greg Kroah-Hartman

speakup: Fix 8bit characters from direct synth

When userland echoes 8bit characters to /dev/synth with e.g.

echo -e '\xe9' > /dev/synth

synth_write would get characters beyond 0x7f, and thus negative when
char is signed.  When given to synth_buffer_add which takes a u16, this
would sign-extend and produce a U+ffxy character rather than U+xy.
Users thus get garbled text instead of accents in their output.

Let's fix this by making sure that we read unsigned characters.
Signed-off-by: default avatarSamuel Thibault <samuel.thibault@ens-lyon.org>
Fixes: 89fc2ae8 ("speakup: extend synth buffer to 16bit unicode characters")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240204155736.2oh4ot7tiaa2wpbh@beginSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 813f008d
...@@ -208,8 +208,10 @@ void spk_do_flush(void) ...@@ -208,8 +208,10 @@ void spk_do_flush(void)
wake_up_process(speakup_task); wake_up_process(speakup_task);
} }
void synth_write(const char *buf, size_t count) void synth_write(const char *_buf, size_t count)
{ {
const unsigned char *buf = (const unsigned char *) _buf;
while (count--) while (count--)
synth_buffer_add(*buf++); synth_buffer_add(*buf++);
synth_start(); synth_start();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment