Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1460323rdb; Mon, 4 Sep 2023 15:12:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4F3HtTVSP9Eo4SCTa3dBpUZ1gbphD3DI9Wus7t85BTxnoP71MNFXh0ohSKL21hL76pnRA X-Received: by 2002:a05:6a21:6d95:b0:152:4615:cb9e with SMTP id wl21-20020a056a216d9500b001524615cb9emr4270713pzb.13.1693865535238; Mon, 04 Sep 2023 15:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693865535; cv=none; d=google.com; s=arc-20160816; b=zQC9AMpQlMbzGxsdEwGNkw8+D+QIsZkPx4i0t2H0Ousi5e98aXv2uNS4AwLX4ICQjC YDr+4MkwqJ7SYY+Q+q6jW0QgNOPSkPTUImS58ufITzcaekHSq0z5nToMjAFlhqk8YsS3 /b51XQX7W3+mPtzwsRgRbFvykyWlaQH7SpfQoL8253fgWPM0rRsTM8r49DdTAQJU93R8 rteDAvBDzQwW3iWpibOCWksyGy1qT7U+IWOZZOEpjp27nASLq1QZsTQLWu5Mi2bj6HP0 dvYQuzLFIkPX8Rokm/Y7rN4ni0upx4s3qDLRlgUxTvXRpN3RS+9tjHbtSW/Nbt9GljfQ vc+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:organization:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date; bh=PUUgL6aTBceQSfSZXV9o0n/Pfkd1gA9yaKCHNIzJAGU=; fh=v8pHy47WIdcWDGS2LGPE+0GDVuchcZpLP0dnP1y+aQw=; b=VO9dAIZKl1tN2M99cO6DNHyN2SSPcgJwhcq2ZBxzNpf4Ce9Fk4DqKUOOqfSSAOEpEr BhoEXUIesLISkCRWOGoZSZDLU3dXPg4yGC9VytkW3i0JHyCuGymk/UC7gFeoayZevYST o8DhHooAMRpDM+GBxlrOq7LO2yyrsqxOp6d5L5F4cR/e5zsaFzNdyfAXbrnLwN379kEh Uv9TUoPqPJI1RtpN301I5nDUiK15Jn91rNoA7i1MWMu0GRtoVG23Y0kh6x+Exp68UbCW E1zl/KmrjWjLO44Aiuf61kd9/B+Lso7oRZsyu2NoUTRkHGcLQRasftqwVXkCRtqK0OZk HXHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r203-20020a632bd4000000b0054fdf58c23esi8323313pgr.680.2023.09.04.15.12.00; Mon, 04 Sep 2023 15:12:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233410AbjIDTgq (ORCPT + 99 others); Mon, 4 Sep 2023 15:36:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233213AbjIDTgg (ORCPT ); Mon, 4 Sep 2023 15:36:36 -0400 Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AB701A7; Mon, 4 Sep 2023 12:36:32 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 6882820152; Mon, 4 Sep 2023 21:36:30 +0200 (CEST) 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 hfugnFnfAGl4; Mon, 4 Sep 2023 21:36:30 +0200 (CEST) Received: from begin (lfbn-bor-1-1163-184.w92-158.abo.wanadoo.fr [92.158.138.184]) (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 A62C120155; Mon, 4 Sep 2023 21:36:29 +0200 (CEST) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1qdFN6-00D65a-2I; Mon, 04 Sep 2023 21:36:28 +0200 Date: Mon, 4 Sep 2023 21:36:28 +0200 From: Samuel Thibault To: Christophe JAILLET Cc: William Hubbs , Chris Brannon , Kirk Reiser , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, speakup@linux-speakup.org Subject: Re: [PATCH] accessibility: speakup: Fix incorrect string length computation in report_char_chartab_status() Message-ID: <20230904193628.movlpsvxnxre6vy3@begin> Mail-Followup-To: Samuel Thibault , Christophe JAILLET , William Hubbs , Chris Brannon , Kirk Reiser , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, speakup@linux-speakup.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christophe JAILLET, le lun. 04 sept. 2023 21:31:44 +0200, a ecrit: > snprintf() returns the "number of characters which *would* be generated for > the given input", not the size *really* generated. > > In order to avoid too large values for 'len' (and potential negative > values for "sizeof(buf) - (len - 1)") use scnprintf() instead of > snprintf(). > > Fixes: c6e3fd22cd53 ("Staging: add speakup to the staging directory") > Signed-off-by: Christophe JAILLET Reviewed-by: Samuel Thibault Thanks! > --- > I guess that the -1 in the 2nd snprintf() call is here to overwrite the > ending \n. > --- > drivers/accessibility/speakup/kobjects.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/accessibility/speakup/kobjects.c b/drivers/accessibility/speakup/kobjects.c > index a7522d409802..1eea7c492875 100644 > --- a/drivers/accessibility/speakup/kobjects.c > +++ b/drivers/accessibility/speakup/kobjects.c > @@ -92,9 +92,9 @@ static void report_char_chartab_status(int reset, int received, int used, > if (reset) { > pr_info("%s reset to defaults\n", object_type[do_characters]); > } else if (received) { > - len = snprintf(buf, sizeof(buf), > - " updated %d of %d %s\n", > - used, received, object_type[do_characters]); > + len = scnprintf(buf, sizeof(buf), > + " updated %d of %d %s\n", > + used, received, object_type[do_characters]); > if (rejected) > snprintf(buf + (len - 1), sizeof(buf) - (len - 1), > " with %d reject%s\n", > -- > 2.34.1