From patchwork Wed May 7 14:17:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 888065 Delivered-To: patch@linaro.org Received: by 2002:a5d:4683:0:b0:38f:210b:807b with SMTP id u3csp406953wrq; Wed, 7 May 2025 07:22:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV/aMTcaSGcn5dhoFDQINR5bPFrghr+2221KT3OUcn4q3E+3fLmT8PbnzpA/YaP3E1oMw09LQ==@linaro.org X-Google-Smtp-Source: AGHT+IGIgFYOuNxONae41/t7Sgxgpmv0FQTjz0NQo7HJpEhXfUn/WfmoCxaAANDfske8EZ+xcGzb X-Received: by 2002:a67:e711:0:b0:4bb:c8e5:aa8b with SMTP id ada2fe7eead31-4dc738bc384mr2978552137.22.1746627775943; Wed, 07 May 2025 07:22:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1746627775; cv=pass; d=google.com; s=arc-20240605; b=csNOCNxNU9BCfzK3Qm43NAZhSa99PoxcyttaEDLWZ5bEeLQrOARTSpKoVTP0RLJ4BG usKjNkzBNEHa4Nx2mwM3v7MlnPvsssUYeIVSgnc01jX2YupvIhI3PQhon+2W7nDV1OQB L4t/Ai4YvRti1ZWu2JFQjg1/K/Q1e4mwJxe+pMYbq6Pn16QApq+ix1FzNlg8Ktybyc0w JaHJ8fK6mYqwrJHUSSnsm+l871WbYbak8weTBGtnxPKELyeQJzKIP+jPtfSVWtMSyJop M6yWwrg+74j9JKpxomQu3phifSQJO+2V1gQDNzJ/EGCFlLgh7aEo/eTPQBI8g7gV4P6G +5mQ== 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=U30Ej1Mm52k6nZq1S6BJ+pXdhraMCTapq8BUrRUStUY=; fh=v2Nv3k9i7Amxu65q1mEuFELTOLzYYycJBMRhbhFxZhE=; b=k3pDGn9F8eaI3srC/dJ3tjYRMpWQnRjfuLvTm5bc9cl/DD9QMG7P8AzaRfsRIvJBwG pWu0kjw53VVLPIBK2nkt9+L3O4hWb+z/HdA5HXz+NK/+MI8O1U0I3qEuvmNnQWCiEdZg Lb3YprTLu+50OnBYAx/aGz2+UQVAwvR6hHXswl8Pi7Y0wZQGKK8VIygN/vz/yhe4kZEz biAJ4QqzxCbp4uA7R9wNBrdb2EudjwtCcEfF7uw0pHmvN+twqhctDXt/tfaKD1WIH/RJ 5leDGIysNpqyKN5ExYCd2esHdp6u0nokGcv62r9PvLx0bYJutV5/ApEcFJ+uj9/qXqvt q4Zg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dtsi3OWz; 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 ada2fe7eead31-4daf2586dc0si2976154137.466.2025.05.07.07.22.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 07:22:55 -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=dtsi3OWz; 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 6D2093857C4F for ; Wed, 7 May 2025 14:22:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D2093857C4F 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=dtsi3OWz X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id 919593857BA7 for ; Wed, 7 May 2025 14:22:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 919593857BA7 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 919593857BA7 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1035 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1746627735; cv=none; b=rXOBPlqCC5TSbBGW3AgI8knCUrGyqO/eFmsQEyvpgrPwv3HPiNIkGu/Qr7Nm+fz3Q3MCs58yFDiara3DOWBUKZ9ngU8KsKszUngeDdgePX6vh/sClqxfD8On3uFLmxanpqVZ/Qk2OIO4f2IzwYsUnN9PMCC0E8B99oxWB3g9tao= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1746627735; c=relaxed/simple; bh=0WHm2sm6S0dV7DI48jwoFtWs4Pct+skLZdcOIf9iCHM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=t8E8S59tl4RCzh0GqoA49KCV9pmC5hrSynjviD4AZ0ncph742ArIXBabwHZrojd9oHlZEmpJJ2Cmb3mmn/BMszAP33uKL68bS/+auPPfhCfNdE8SMjC3vjer8MSbK0jq2DsRiqLZsmMfHNUaC2nXYrU518ZGQJ3D/78pusR38iA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 919593857BA7 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-30ac5cc0df4so582813a91.2 for ; Wed, 07 May 2025 07:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1746627730; x=1747232530; 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=U30Ej1Mm52k6nZq1S6BJ+pXdhraMCTapq8BUrRUStUY=; b=dtsi3OWzBFhT7z+MHgPM4GaQT4mfPrHavGPikpUdig43dsFIJxuRAo+l0ymik7ALhd VZYImdCKRCM580oxjsNw07dLPBQcEG73cd00D12NdU7RydV9KLx/imixWB9u7pbyJkrC bhvR1UnqPVmZUz8bo7KTaUiCIwDOY5YEVeTe7HO0/+7PvCCqmRur7vTwoPiKFj+WYQww Lus2Y9p2evdiC1VMFtUjL8xV9/cFjDVWofW4BzJ/fFlsX3INd1WMDCALiBgUwI9cQ04C IK+3tafN2ZvJph0j3Ah0QeUY7P3Ykep3RMGLKtpOds/oCJ1Zo4crX4VO0ggQNvuj6g3n bgkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746627730; x=1747232530; 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=U30Ej1Mm52k6nZq1S6BJ+pXdhraMCTapq8BUrRUStUY=; b=tJ6LfpYBmyWpzFoApThmp3FLea2dhnrrYj68p/khV831GsqjOfJjoIEQsc9k5K1H1g 0D6uIWf75SWJJQBZB5fiUG1jBrU/AuugEl/L4kQFB6pDUr/g0/C5WJusSiFuwHqsE8DN Z2eOH04DtjCSrNeNX8YuerGpB1Tnpk7gbqoulvqivGtKt2DCSuisZm90GBJWVg6dJhlx XmHHgJ/TAxD3T93AfGtSegFvJLShleE59Yt+GZ2u8ZvcW+F5L6rDx9LOKGSjuhnkjPur QwhyTHmoVpuTTC0XdLNfHbhVGQSdryIIsDUirlnMy1e3Obodsf/72qffeyanFdXNJYRI pAaA== X-Gm-Message-State: AOJu0YzAMhtMpOqSYeTSMAuL8ki5v2P0wgZoKbXrrj1kkHpnjfAvKa4J a1Tgt1ST7ORe3mO7KXpDsYByhEyxZlo/LqsxZRiv/vO12T9dQQdhqbPuxQyo/T8rVQZy8+n+ZcC B+Mk= X-Gm-Gg: ASbGnct+0AAZEzdPoeTK6ccZaeTle8K3lR6IFwYOGpicKrq/yrRsebYDd+iT56IgxE+ mhfDP176o+vaq91lyuIAryI/b6mGJJFqWQzXYuJOvRxfweoMVkaXtKc7EDq1FIeAvYGdfeOQnJ0 kcEzjcgXloaYgScRmA+IfxKVWG6wA3VW6gpePXgDTH2xQOLebXkdmvp6cVDtZmqos1whFTER+as 7ExysuITuN/Nq0O8e138yN7b2+Xc0U2Y4uIXE0Z2FGBbdvdeAuno6EDtKarBy8gSb+x+NJWzZyj Lwm3lI27mYVzYjSrKKto++5OQEESR5uQ4MhHgc9B5TRqqWMFPfUegg== X-Received: by 2002:a17:90b:3a87:b0:2ff:52e1:c49f with SMTP id 98e67ed59e1d1-30aac28b70bmr4689311a91.26.1746627729811; Wed, 07 May 2025 07:22:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 07:22:09 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Carlos O'Donell Subject: [PATCH 05/11] locate: Fix UB on memcpy call Date: Wed, 7 May 2025 11:17:23 -0300 Message-ID: <20250507142110.3452012-6-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/charmap.c:908:2 null pointer passed as argument 2, nonnull attribute declared at unknown:0:0 This is not an isseu since size is always '0' in this case. --- locale/programs/charmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/programs/charmap.c b/locale/programs/charmap.c index 58433c8c5b..07d406e12f 100644 --- a/locale/programs/charmap.c +++ b/locale/programs/charmap.c @@ -904,9 +904,9 @@ number of bytes for byte sequence of beginning and end of range not the same: %d (struct width_rule *) obstack_alloc (&result->mem_pool, (new_size * sizeof (struct width_rule))); - - memcpy (new_rules, result->width_rules, - result->nwidth_rules_max * sizeof (struct width_rule)); + if (result->width_rules != NULL) + memcpy (new_rules, result->width_rules, + result->nwidth_rules_max * sizeof (struct width_rule)); result->width_rules = new_rules; result->nwidth_rules_max = new_size;