From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by sourceware.org (Postfix) with ESMTPS id C4CDB3858D33 for ; Thu, 29 Dec 2022 12:58:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C4CDB3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-x236.google.com with SMTP id s187so17055366oie.10 for ; Thu, 29 Dec 2022 04:58:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=OdZJwcrTC9+ew4Y8MiWGM4S18l0h3KaFtBGQksYraYM=; b=GpZ+AiEfQWg2lAFh7yUyYrotQfufAnGgRzVSVJznLhiz9lUZoxmK3oVwsaXvxf+JVb dHIpWIyB8LzVHm8fdFUnNF3QTAdIwz4hUvXZmWW1PqH9peZBzueG/T6/3QqZWhBKtOtW uiNFGCTPvptIbZ3wVBFOauUyBv2Q8i7e7Pk/oqy5A0Uy4bTIN+Aa3kgMMBHbQe2xBlGj gmNoVWOImMjfS9UC6eOBsCuA1KGHS9SVqVjvk2aN2tsavQCgCrzr028vbTw0OInPKeRq B+5ISIMXgUhWXnpnCb9LgIE9j1/LgSwUCE3ePP8kBIuZ2yqWe/7rEG7WDke938C0rw5p uZgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OdZJwcrTC9+ew4Y8MiWGM4S18l0h3KaFtBGQksYraYM=; b=1ePEsF0JDy5w04bciDquE3VuojHoKXMp9oscxop+R8HVP8/6xTcb1/gitOEVTAFd4l ufmR+nQ8tp33sTruy5k+hMGsgZ5NIUcOL4JkC6rEtjW5fzRM0igF9VG8GFT6HXAG/N1z HNN4qVnoN0gCpoiXPBe0NtTJwCfZdy3Mk56OiYPgfocyzmD5Cae3rCZH+CDmIXBnzSNv ttqT94TBuq86L+LVNSDrO/UrJ7D9kOHQdg/yyDApd+hMVpFk1XutKAH/ShgK0MhZtFUs wJpX4kOpSdtv7x2ikrs3lTdJhNf59V+vT8WnWxIPPnI0cld9oZAcVa0qot0I2/+maqgi SnXg== X-Gm-Message-State: AFqh2kofRYV5ouzgip++NwLWo5FsXOm/QgD3K89ES+ZK2ap8eFmRKELs gBpyDqOfXPtoZdQbFf7rPpWYoc2xGCl2jw/eD0s= X-Google-Smtp-Source: AMrXdXtX+VP44PG/FVIGXTEPEr4yIK/D5H8+ssbiFyCqgcuZKmE4cLV6acDBsjk/n4byMxVNuXiGmQ== X-Received: by 2002:a05:6808:200d:b0:35e:823e:87a6 with SMTP id q13-20020a056808200d00b0035e823e87a6mr16812739oiw.50.1672318688672; Thu, 29 Dec 2022 04:58:08 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c3:dd36:4794:7acd:a716:7b01]) by smtp.gmail.com with ESMTPSA id j2-20020a9d7d82000000b0066c34486aa7sm8977378otn.73.2022.12.29.04.58.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 04:58:07 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/4] locale: Use correct buffer size for utf8_sequence_error [BZ #19444] Date: Thu, 29 Dec 2022 09:57:59 -0300 Message-Id: <20221229125802.2715435-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221229125802.2715435-1-adhemerval.zanella@linaro.org> References: <20221229125802.2715435-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The buffer used by snprintf might not be large enough for all possible inputs, as indicated by gcc with -O1: ../locale/programs/linereader.c: In function ‘utf8_sequence_error’: ../locale/programs/linereader.c:713:58: error: ‘%02x’ directive output may be truncated writing between 2 and 8 bytes into a region of size between 1 and 13 [-Werror=format-truncation=] 713 | snprintf (buf, sizeof (buf), "0x%02x 0x%02x 0x%02x 0x%02x", | ^~~~ ../locale/programs/linereader.c:713:34: note: directive argument in the range [0, 2147483647] 713 | snprintf (buf, sizeof (buf), "0x%02x 0x%02x 0x%02x 0x%02x", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../locale/programs/linereader.c:713:5: note: ‘snprintf’ output between 20 and 38 bytes into a destination of size 30 713 | snprintf (buf, sizeof (buf), "0x%02x 0x%02x 0x%02x 0x%02x", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 714 | ch1, ch2, ch3, ch4); | ~~~~~~~~~~~~~~~~~~~ Checked on x86_64-linux-gnu. --- locale/programs/linereader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locale/programs/linereader.c b/locale/programs/linereader.c index 0460074a0c..794f25a6e4 100644 --- a/locale/programs/linereader.c +++ b/locale/programs/linereader.c @@ -701,7 +701,7 @@ static bool utf8_sequence_error (struct linereader *lr, uint8_t ch1, int ch2, int ch3, int ch4) { - char buf[30]; + char buf[38]; if (ch2 < 0) snprintf (buf, sizeof (buf), "0x%02x", ch1); -- 2.34.1