From patchwork Sun Feb 4 15:57:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 196528 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp415497dyb; Sun, 4 Feb 2024 07:57:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGs0QMf0xfanAoRpziGIfOY4fbzFNk85VsXf9eltXnZNQH6RPkJErdRLqxku3q3vpiAbJaL X-Received: by 2002:a92:d08a:0:b0:363:b281:a1ac with SMTP id h10-20020a92d08a000000b00363b281a1acmr7582069ilh.9.1707062276613; Sun, 04 Feb 2024 07:57:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707062276; cv=pass; d=google.com; s=arc-20160816; b=WSCgKgLJls+b55MP6ma6GKaxpL6zumN6jTkxdo2qHboldJoaJBFX2HM5eBHT/lW/4q Get5fvv8AsxVzWjiN0FYw/uoJUhcs5V70PMecnuO5HgPoOg9glLzlpjIyNPuJRCtnoI8 w3zmGEkmtkRIfmjNBbFL0TDuxJY7EIBrGLoRoWUzMHFv+vA0FMJElzHvIag2stda+1/M 0DF8cUbIalULwgVUirlqOXq6TmQq2D07swBN7ukM7C8pzBNjpz2m9DdQjktzaHzSMBOa H/gPEZ67xedJp17UQmTPdKt+ArIJSjRQphslzOw52Xdlku4sraB9CIXRgqfD840YpMCr MC4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:mail-followup-to:message-id :subject:cc:to:from:date; bh=mkw46NN3wfwELyO90JcCctJsq8mfEqHyCYSIX9XbX2w=; fh=weXVR+9N+Ju4IhBvM5kRoDj8L3AbXStG7N4ph1sc0f4=; b=k4XkR+byGW7rRoOp5l/NY5KulrEzy+0AMgw7zsLpgmfaVCuNHUPThXaozpL8dJunoo U2tvQrcBob3jfur4QduerVfO9DpSu4rsv2tqXF+FX7RnDpLXKviHGOoZQeYVqtkR7fJt a1FAjsc/t5xnmQus5aqReHxxTFMOgvXyiVy+95AdC0dDSYucCum6L/YpbTdMIctZMqBM awaJMd8oESX4QKV7kBHghNC4cNlrfVUapvQETtt1t9rfxyheLpYQjOqOsMcaYduqKCHL DxRqwx+poXIEtpIoef91OdF8aaJTXf903CQaOf52FxJSegmbt7SDmmSTyhpwNaqR1zOn Acbg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=bounce.ens-lyon.org); spf=pass (google.com: domain of linux-kernel+bounces-51765-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51765-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVOH6opkbvIpD+Am9dUYd9NbZ4rN9P1cxC+HemoA1JOEOziXKKZ4T+msTXM17U2uK/o2UDYQiP0hMheRrvLsBquvMS1dQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y14-20020a05622a120e00b0042c1bc6987bsi1751567qtx.59.2024.02.04.07.57.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 07:57:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51765-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=bounce.ens-lyon.org); spf=pass (google.com: domain of linux-kernel+bounces-51765-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51765-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 64D691C21D62 for ; Sun, 4 Feb 2024 15:57:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EAF922EEF; Sun, 4 Feb 2024 15:57:43 +0000 (UTC) Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55D70225B2 for ; Sun, 4 Feb 2024 15:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707062261; cv=none; b=D4JnXyA4m1mWpr6eeePl7QQ800r5BuhC1+qJaANjOdmQbKZ6gMPEyMU0uysMF4Hfdut1bQatWBD8s3mPILNgxFl/7ry1FOc3Q/vluXpwsXA7LTnJYmOFW4kro5R5Td5eRf1KUi6vEitDw6gs0dXLw56AIZO7IliwozXmF8VQfEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707062261; c=relaxed/simple; bh=AXPeDLFZd5lvWg0r9XsdD0jCLFcFq91QvmlBpnnJNyQ=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=dIeiQQi8dG9guBh8Cwqc4RgD7o4RiQj3rc+4kX4vezX5HoBpxgvimdj6M/i3lrDYNKuo3YS67IFVIu+j6Kt9NetOr0hfIf0lbUZJNzX6V9Sv2MjgNPBSAF7UBcUCueyIbyNPTuEIKDPe9S2gZJVO5Th1TxH0gBZukmhg3BbrEa0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org; arc=none smtp.client-ip=140.77.166.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id F09E3A02C1; Sun, 4 Feb 2024 16:57:36 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JLfM5EvYB1wa; Sun, 4 Feb 2024 16:57:36 +0100 (CET) Received: from begin (aamiens-653-1-111-57.w83-192.abo.wanadoo.fr [83.192.234.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id C969AA02C0; Sun, 4 Feb 2024 16:57:36 +0100 (CET) Received: from samy by begin with local (Exim 4.97) (envelope-from ) id 1rWesC-0000000ERlw-1iWL; Sun, 04 Feb 2024 16:57:36 +0100 Date: Sun, 4 Feb 2024 16:57:36 +0100 From: Samuel Thibault To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, speakup@linux-speakup.org Subject: [PATCHv2] speakup: Fix 8bit characters from direct synth Message-ID: <20240204155736.2oh4ot7tiaa2wpbh@begin> Mail-Followup-To: Samuel Thibault , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, speakup@linux-speakup.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170609 (1.8.3) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789984533523596214 X-GMAIL-MSGID: 1789984533523596214 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 Fixes: 89fc2ae80bb1 ("speakup: extend synth buffer to 16bit unicode characters") Cc: stable@vger.kernel.org --- drivers/accessibility/speakup/synth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Difference from v1: - Add empty line for style. --- a/drivers/accessibility/speakup/synth.c +++ b/drivers/accessibility/speakup/synth.c @@ -208,8 +208,10 @@ 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();