From nobody Fri Oct 02 20:01:48 2026 X-Original-To: dev-commits-src-all@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 4hxKRx0Rx1z6vy27 for ; Fri, 02 Oct 2026 20:01:49 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hxKRw6xbtz4Rg4 for ; Fri, 02 Oct 2026 20:01:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790971309; 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=miR7qa7kHyT45Jg0Kk2M1npsNfiS9OMCvKnVRd3sFl4=; b=wcu3zPm9ohazDGYqMxSajYosDBnnyhc4yo54TjJu6H3GdvdqL2Jk7o2fTzqRdnnTHnQRme dzjymJPwvjDlN92XjZqXyqgrk1cJxbwQwDox7PpIyrJEW8YFZsnIWzYEkB1iG4EDPN41SE ZmWjy86ErzoseBRymCDi8+UFBlS9AowdpLZZPwROKq/t9cbxErhDZ9om8t7nWzQAml3+bk xxo6O2U9CeD+YQHqmNeR+kQVzo+Pgu9uHRyWur3kmlqvfUiZuEEqn5vmIDv43Inur8bh5K ssZTU1L4/cHWbPG1q/gpx1ML/IyvkjSw/Iu3qiq+EtMg9KbuH8tgnae1Fs7xaA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1790971309; b=FNkQxrT7+OYvojeg6ULUQyPhDnHTdg4CwMxWFS+9OTNjmT1pU6mPOFfTdmTAaACj9YwTxb f8+wbqY/oLzGE87Oq3o7SuX5gfM26uj3eh9gTbPA4iW1Wltuvx8sj/DNWotrlQHR4o5CSx sj9ZNT7Y/zD12KqMiEXl8KKONn2cS8VKg8ahGchm3WeO4/3S2k89k+FDkAFZly8fDW53qj aDED0E9QM6CCdg0MCfHAD9zCTkDMfriIOK4lrNpV3ZKA6pBF2Nb3h29sooX+fOFrNeSTul fqre9zso9zUiCW6UTMoAE8by5hZ6i9quSoSf4vW2eqgjQlPypwOHfx3e2isnqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790971309; 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=miR7qa7kHyT45Jg0Kk2M1npsNfiS9OMCvKnVRd3sFl4=; b=Y7KiLr1iV8ulzWiVxJe7zw/WyYrHoiSLqrsVJO9imG9L2IkBmT0AxrekiPpuQeggFMqzxc wl8YY8T5kpO+fAQXTLT0VlEKgXX8F94jWHI9ItykQXzfAxzLGRrqFYcEYw+wkWhtRQ3qhe DzAjMRpWN4tAbfp9LQUf85PF8mrBlbbsKlSb+UD9edNHRf6+jcKthZ/SO4k8yDQsqTyrCW mjLnrWRQ5FS2js+jsVYk9+4lgQ84S2wk6jKe+PgvPTeCqvkxag+/CQcz/83WnTnu1BUrHh BkXMQVvC32k/nmPOqvQ/R3mGFESdwqwwdp7Gb6c30B8Kjo9gp+Ggp0U9HOvLlw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hxKRw607fzYWC for ; Fri, 02 Oct 2026 20:01:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 34611 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 02 Oct 2026 20:01:48 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: dec68aeff8ce - main - libc/stdlib/getenv.c: always allocate new environment List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dec68aeff8ce0ce154e93325a74bba6af71c87af Auto-Submitted: auto-generated Date: Fri, 02 Oct 2026 20:01:48 +0000 Message-Id: <6ac00dac.34611.16e56183@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=dec68aeff8ce0ce154e93325a74bba6af71c87af commit dec68aeff8ce0ce154e93325a74bba6af71c87af Author: Konstantin Belousov AuthorDate: 2026-09-24 18:30:57 +0000 Commit: Konstantin Belousov CommitDate: 2026-10-02 19:48:42 +0000 libc/stdlib/getenv.c: always allocate new environment in particular, if the old environment is NULL. Among making it less surprising for userspace to observe NULL environ, the change also prevents NULL deref in __rebuild_environ() when terminating the empty as NULL environment with the NULL pointer. Reported by: Leo Bicknell PR: 298747 Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D59996 --- lib/libc/stdlib/getenv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c index c1d0b7a559d5..1fff081002e2 100644 --- a/lib/libc/stdlib/getenv.c +++ b/lib/libc/stdlib/getenv.c @@ -268,7 +268,7 @@ __rebuild_environ(int newEnvironSize) int tmpEnvironSize; /* Resize environ. */ - if (newEnvironSize > environSize) { + if (newEnvironSize > environSize || intEnviron == NULL) { tmpEnvironSize = newEnvironSize * 2; tmpEnviron = reallocarray(intEnviron, tmpEnvironSize + 1, sizeof(*intEnviron));