[Bug 298747] clearenv() segfaults when the environment is already empty
Date: Fri, 02 Oct 2026 20:02:39 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=298747
--- Comment #6 from commit-hook@FreeBSD.org ---
A commit in branch main references this bug:
URL:
https://cgit.FreeBSD.org/src/commit/?id=dec68aeff8ce0ce154e93325a74bba6af71c87af
commit dec68aeff8ce0ce154e93325a74bba6af71c87af
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-09-24 18:30:57 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
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 <bicknell@ufp.org>
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(-)
--
You are receiving this mail because:
You are the assignee for the bug.