* [PATCH] speakup: Fix 8bit characters from direct synth
@ 2024-02-03 23:36 Samuel Thibault
2024-02-04 0:03 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Samuel Thibault @ 2024-02-03 23:36 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, speakup
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: Samuel Thibault <samuel.thibault@ens-lyon.org>
Fixes: 89fc2ae80bb1 ("speakup: extend synth buffer to 16bit unicode characters")
Cc: stable@vger.kernel.org
---
drivers/accessibility/speakup/synth.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/drivers/accessibility/speakup/synth.c
+++ b/drivers/accessibility/speakup/synth.c
@@ -208,8 +208,9 @@ void spk_do_flush(void)
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--)
synth_buffer_add(*buf++);
synth_start();
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] speakup: Fix 8bit characters from direct synth
2024-02-03 23:36 [PATCH] speakup: Fix 8bit characters from direct synth Samuel Thibault
@ 2024-02-04 0:03 ` Greg KH
2024-02-04 0:16 ` Samuel Thibault
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2024-02-04 0:03 UTC (permalink / raw)
To: Samuel Thibault, linux-kernel, speakup
On Sun, Feb 04, 2024 at 12:36:00AM +0100, Samuel Thibault wrote:
> 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: Samuel Thibault <samuel.thibault@ens-lyon.org>
> Fixes: 89fc2ae80bb1 ("speakup: extend synth buffer to 16bit unicode characters")
> Cc: stable@vger.kernel.org
>
> ---
> drivers/accessibility/speakup/synth.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> --- a/drivers/accessibility/speakup/synth.c
> +++ b/drivers/accessibility/speakup/synth.c
> @@ -208,8 +208,9 @@ void spk_do_flush(void)
> 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--)
> synth_buffer_add(*buf++);
> synth_start();
Nit, I think you need a blank line after the new variable definition.
And why can't we just change these to be u8 instead of "char"? Wouldn't
that solve this issue overall better? We made much the same type of
changes to the tty layer recently.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] speakup: Fix 8bit characters from direct synth
2024-02-04 0:03 ` Greg KH
@ 2024-02-04 0:16 ` Samuel Thibault
0 siblings, 0 replies; 3+ messages in thread
From: Samuel Thibault @ 2024-02-04 0:16 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel, speakup
Greg KH, le sam. 03 févr. 2024 16:03:20 -0800, a ecrit:
> On Sun, Feb 04, 2024 at 12:36:00AM +0100, Samuel Thibault wrote:
> > 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: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > Fixes: 89fc2ae80bb1 ("speakup: extend synth buffer to 16bit unicode characters")
> > Cc: stable@vger.kernel.org
> >
> > ---
> > drivers/accessibility/speakup/synth.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > --- a/drivers/accessibility/speakup/synth.c
> > +++ b/drivers/accessibility/speakup/synth.c
> > @@ -208,8 +208,9 @@ void spk_do_flush(void)
> > 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--)
> > synth_buffer_add(*buf++);
> > synth_start();
>
> Nit, I think you need a blank line after the new variable definition.
Ok.
> And why can't we just change these to be u8 instead of "char"? Wouldn't
> that solve this issue overall better?
I was wondering, but an example of caller is synth_direct_store, which
calls string_unescape_any_inplace on the buffer, which does take a char*
and I guess won't change.
Samuel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-04 0:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-03 23:36 [PATCH] speakup: Fix 8bit characters from direct synth Samuel Thibault
2024-02-04 0:03 ` Greg KH
2024-02-04 0:16 ` Samuel Thibault
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®