From nobody Thu Nov 06 07:13:02 2025 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4d2D1C0f9Cz65BMw; Thu, 06 Nov 2025 07:13:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4d2D1C085rz3J3m; Thu, 06 Nov 2025 07:13:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762413183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Tbq5P007gkTS0rqNMH1Q4omtW9jLrzPR1IDLfwT5dqU=; b=GV0wDnO08eg8LL3FL+Lo4sw9JHTm7C2Hj0lq9KMu8j1T6uj7xBBVjeYbOTorJFbv8ugVRv HDP55yn68PWmp+k2TFBwmzfxssoaHKQX6X15SQkimsnB/2N+eJBXj1tpXmuk6YrJXx6Uqr 13ErgqOdve5FH1h12YhLawoUW2McPKjknur1Z3tk4y3t2m/sd0cHaeM2Gwf9ORIf6z5Uwf sx2ll5LoHzPMugU/D/e+3EJErG6efA7JB2rCGZT2xqjpZkVs6gV9ccTJu9BKNJj+uXemNk f/M+jocSb7bzJNBqlvsGbs8XGUGvvPWcj18y4Oaio5Q/PhdRio+0xaLlbYKElw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762413183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Tbq5P007gkTS0rqNMH1Q4omtW9jLrzPR1IDLfwT5dqU=; b=YIVpPoY7hYMZFh85mFHmIDPEbZvjyX3aHz2UQFk97X6zHfgF5Vb51o0vKBYIf/f9nCT6jV rB/0ULI7hsEY/B0Y3OEek8DhJX+578wdXqvnRz/afRaMFZ7agDEERlT7oiRWkyVd6uTC96 C8bjua8wzXW6tM0Gel+ufFyzKdYs2IJnxHX/K7bikRXc/r8ezsuQZvLyfhcPgXrGLaJqa+ 3clQ1JfHsTcACf8OreQWfpYVLE6/le78zXvmHP9ZrIaNeOSCP0L0sJiXxOMYzuL6r/w2WU shv2hwfjgPQ9Fo2nCql3eM0q6w2cSyY7B28eLPG+jvs7yLtkesT0I0qW/Jc+ow== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1762413183; a=rsa-sha256; cv=none; b=eJhdpLPL6UPsIhPDNoFvBFj0Kq9bWFtkKFg/20YxehE7OX1QE0ttisNtK39QtTjNr2KLnz tp6JrkH0LWm/OTZibtV3XMOmtFgK+fbC9Tgrigi4s+s9Wq2NIkSEFJOR6AZgEwkivn+tZO 7iwBFJWUwfXSazkPQ/6EF/fEVAS3q2DRAokaPQL3ARJiLkvDqbbMfgPrSHdJM5P3usnTb9 3gLx8icTIkSKGuwhD3DZt6934/BUdzwhAjh1zcW2bRCm0XIVIh8CGR64+ddbNgXcGjq6E8 KJVNajTXQLrsPJ+ZRDEm8OO+DHLeqET9vxLoMqOtK2y0rTswKmjODbk6gcKotg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4d2D1B6py6z1J4f; Thu, 06 Nov 2025 07:13:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5A67D2tv002820; Thu, 6 Nov 2025 07:13:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5A67D2L3002816; Thu, 6 Nov 2025 07:13:02 GMT (envelope-from git) Date: Thu, 6 Nov 2025 07:13:02 GMT Message-Id: <202511060713.5A67D2L3002816@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Xin LI Subject: git: c23a589aa145 - stable/14 - cron: Use reallocarray() to prevent integer overflow List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: delphij X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: c23a589aa145d2f14e7141601fec1b38bce9a6bd Auto-Submitted: auto-generated The branch stable/14 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=c23a589aa145d2f14e7141601fec1b38bce9a6bd commit c23a589aa145d2f14e7141601fec1b38bce9a6bd Author: Xin LI AuthorDate: 2025-11-03 05:59:46 +0000 Commit: Xin LI CommitDate: 2025-11-06 07:12:52 +0000 cron: Use reallocarray() to prevent integer overflow Apply OpenBSD env.c,v 1.24 and 1.25, which replaces manual size calculations with reallocarray() to prevent possible integer overflow. (cherry picked from commit 40d21618382108fefa84f8576b14302f65452718) --- usr.sbin/cron/lib/env.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/usr.sbin/cron/lib/env.c b/usr.sbin/cron/lib/env.c index 36c5fca12117..b4dcf4ac5325 100644 --- a/usr.sbin/cron/lib/env.c +++ b/usr.sbin/cron/lib/env.c @@ -58,7 +58,7 @@ env_copy(char **envp) for (count = 0; envp[count] != NULL; count++) ; - p = (char **) malloc((count+1) * sizeof(char *)); /* 1 for the NULL */ + p = (char **) reallocarray(NULL, count+1, sizeof(char *)); /* 1 for the NULL */ if (p == NULL) { errno = ENOMEM; return NULL; @@ -115,8 +115,7 @@ env_set(char **envp, char *envstr) * one, save our string over the old null pointer, and return resized * array. */ - p = (char **) realloc((void *) envp, - (unsigned) ((count+1) * sizeof(char *))); + p = (char **) reallocarray(envp, count+1, sizeof(char *)); if (p == NULL) { /* XXX env_free(envp); */ errno = ENOMEM;