From patchwork Wed May 7 14:17:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 888070 Delivered-To: patch@linaro.org Received: by 2002:a5d:4683:0:b0:38f:210b:807b with SMTP id u3csp409456wrq; Wed, 7 May 2025 07:28:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/Do4s3f0X9tK7ZYR2LLJ4ig/N7o8W1757hHVeDs1AhTKWcvOElMAfOQ780StNjLGbai9Q8w==@linaro.org X-Google-Smtp-Source: AGHT+IHAnaqtMp3ox9QOZBXDe8sjr8ijpLu/iYBXe5RMew0y521e5+Qfk7YwDTTEQnANYAWK4FH8 X-Received: by 2002:ad4:5ae2:0:b0:6e6:4969:f005 with SMTP id 6a1803df08f44-6f542a829e2mr47729096d6.30.1746628117822; Wed, 07 May 2025 07:28:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1746628117; cv=pass; d=google.com; s=arc-20240605; b=DCWYXrbtMApeUTvy1o7zjVsWcJob3gLmeunESs5HwDSGpxp2Nnfq6+A1hYfwS330eN hPIoAwyS/vHuf5nmFuFBGY8zDagk6jRFNG2ymjiXE1+33MeRORHC+7n/7bR/i4jKOt8c Adod6L39m8jmB1fuPexBjPX5xkAYDEKWekoalP38FaPZ5Vnlb8oItTg529JMyQ/xW8w6 zsuIqCu+3D7zpFzsxuaZMOTMJb65ZAZlPpkUoX+EmLnifbt562zrH5xE9YyLji83oWdu tW5DpOs2d2CC5a5YYRSiEA0cC7c5PyuoqA1JbkxwD5/GvCccU/2N1QnS+bnOlg+83Knn Pn+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter:arc-filter:dmarc-filter :delivered-to:dkim-filter; bh=RfYOXC+J2xBWVeEGcvuEAVrgqJT+uMIOS8B0wp2g6ik=; fh=v2Nv3k9i7Amxu65q1mEuFELTOLzYYycJBMRhbhFxZhE=; b=KxLWm1PRKnOQkpnN5kGw01n4f/yLENjL2O69ef1EX75B02zDdf3hgJ81pHB9S+rHpS c7qDidarfPwOHic2eFsU3ffopG0C+3wtHJN91YhboR500T9HiNJmgxtHq3Xq9sUvRutK CIPSh1leAioZbC8T31Cq/yOpGC0wuOzPyUzJZKD0+pFVUvZbIalDN8hhbx/78lQtG13+ xLxZxfS4qXZB9GE9WD2b/wMaIAFIe1y7JVkephs9pQ2sznCnUx277dB6zoS8E4KmxbDg HijT2jr31ptbRnTEFyKWrWFkdLuGx/S/erjRNLEQFts0D+gkIuktap8GX/zfm+J/9Cnd s52g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T9Rmdxl5; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 6a1803df08f44-6f542627cb2si19737586d6.36.2025.05.07.07.28.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 07:28:37 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T9Rmdxl5; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 669D13858429 for ; Wed, 7 May 2025 14:28:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 669D13858429 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=T9Rmdxl5 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 922303858D37 for ; Wed, 7 May 2025 14:22:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 922303858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 922303858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1746627736; cv=none; b=EbUYWgxccXEba7ZNqfoGKoDP3BT85Vz458AcE19DwiqP80n7uSPweyAO5cKww+3kgbCDhjHm5IMLZ8zIuJI7qrgf+QSn9zcBqzWt9BVGx2aDwelnDnpfR4rXEYHlKsASP1DI+FxOAaCAm71bAyrN6mxEPjGQrcyAIWszxl5OCc4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1746627736; c=relaxed/simple; bh=fEG3cc5bmcTQ0AD8r/nXXNK31IxhP9Et1jIeAxpujfg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NnXxyyMhcMZICUZfzsW6AFQuWcmcKxmNfXXUN+sxCvxaGzUhunjCwA7ewDFXTVD3dA9z16s4aHoQSBIrUQgO9PV/TWC84jCsuzA/vBdEreFfL4RzRP+J3qWqBuvFkWJMOUeplftX19JKtYpp/DVRQVnu9s4zZEmEvdjE55Cf5mE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 922303858D37 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-22e4d235811so24614295ad.2 for ; Wed, 07 May 2025 07:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1746627733; x=1747232533; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RfYOXC+J2xBWVeEGcvuEAVrgqJT+uMIOS8B0wp2g6ik=; b=T9Rmdxl58TTfh0QwEW18Rtzwmn9odRScbXjIqakfLeh7ogk0+X7mjOWDNvcFTQ//Aq LUgJcytndp5h1IWO0CwbxygDZQe/qg43s455wLear2RwNkoUtATQEM6+H0L/1Kjj03TH yClMudH5LtPLaA36a5c1cHInJ2PyP97iOMhnAC8upzpYdGG8Zb9Payo1SFCQsCWUlSSE BXR9BBIy8mpfUrkIvvI1VOt321z2oI0lqPTcq+Lg2/pXqt8YkMLM2ZqpTi538IAppShb 611TQRqWaCNtGMFY7XiFiJlnNt+7TaPgUOD21Rtj+b67k3Fjz9BZYQBxKcZY2ppW4fmF Iciw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746627733; x=1747232533; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RfYOXC+J2xBWVeEGcvuEAVrgqJT+uMIOS8B0wp2g6ik=; b=AMCy+O81r0LSxNkejP7tnmAyap/LHxvKZuw6Ufo5imou9pto4ReOgigfcGIG3ygRS1 +bMWqkcpeVJNGsRlDgYfPY/gCyOQssDV7VIvdLs+FH3HI3YcBswhIRjACfgNc8n1kerr Z/zn5jvWi9q8hEja4SLmGuacholF4IojPBaV46jEica+zCRwUE1aGCEjYNZAfN1IXEc6 N/rFSm7vqh1n6HeG7GuzAAUyvS//KORfHFYeKiLHwfkxzBA9icCJMQqJGx6YnV0zC9iF xM6Olg4OYfqajm2DqqFc5aRDqKN9IXYrp/PfmYuRMSgb96k/O61vHJZw6Y0u3KKGN0Nh 6uBQ== X-Gm-Message-State: AOJu0YzXmEfojdAktE+5lyTFxpLaoI7RrkCgPx52hjIDIWA9CEzAd6wm YrUd5aG2wqbIP6bfuXO8/g10MQ6OhT7/hQ9cmEoL1YcVa4NZ0N5oD6mt1cnWP2y7R1MfRjt23Bu Uu60= X-Gm-Gg: ASbGncsGP9YDMpGgpyVIu3okMc5WxdogejagErbDSCkn5hIWC7IcQ1LLT66qRPH6Fjm 8ZEImgFSGnKTHYbJlagrzeD54w7+nkf1kkxwULb/ek4OAXLb47b529Fb8UdpsCfKXNvADDYAU9S Am4W/Nx0g1Atg7z8LoA3Yyei/X4U8TfPG5rcsC2Mf+dKDTBVAIjk+AiM7i14O/Ur3458ry1qIc/ XcdHGGh9GZrlOLp+i8Kj/lZRBsyK61bbrpmx1/3+NZXFWe4R+5o2KS56J9cBPynO14OAaVXCvUc xMZVCI/Ms4/UNSlZmXo0BfoVg8Guop1f1UgblfDCQn1TgUrvpDoxhw== X-Received: by 2002:a17:903:3d0b:b0:223:52fc:a15a with SMTP id d9443c01a7336-22e5ece2308mr50060555ad.33.1746627732852; Wed, 07 May 2025 07:22:12 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:2a60:2bef:3994:10d0:59c9]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-30ad474a050sm179453a91.8.2025.05.07.07.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 07:22:12 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Carlos O'Donell Subject: [PATCH 07/11] localte: Fix UB on collate_finish Date: Wed, 7 May 2025 11:17:25 -0300 Message-ID: <20250507142110.3452012-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250507142110.3452012-1-adhemerval.zanella@linaro.org> References: <20250507142110.3452012-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org The ubsan triggers: UBSAN: Undefined behaviour in programs/ld-collate.c:1557:7 variable length array bound evaluates to non-positive value 0 The VLA is allocated with nrules being 0. To simplify the fix, just allocate one for this case. --- locale/programs/ld-collate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c index 4fa08bd273..5ed03f4cbf 100644 --- a/locale/programs/ld-collate.c +++ b/locale/programs/ld-collate.c @@ -1554,7 +1554,7 @@ collate_finish (struct localedef_t *locale, const struct charmap_t *charmap) The multibyte case is easy. We simply sort into an array with 256 elements. */ struct locale_collate_t *collate = locale->categories[LC_COLLATE].collate; - int mbact[nrules]; + int mbact[nrules == 0 ? 1 : nrules]; int wcact; int mbseqact; int wcseqact;