git: 6d18a7077def - stable/14 - su, login: fix heap over-read in environment export filter
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 16 Nov 2026 15:17:57 UTC
The branch stable/14 has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=6d18a7077defe108f8e345fa7c8017b5efa8112f
commit 6d18a7077defe108f8e345fa7c8017b5efa8112f
Author: Osvaldo Janeri Filho <ojanerif@amd.com>
AuthorDate: 2026-11-12 14:23:56 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-11-16 14:52:04 +0000
su, login: fix heap over-read in environment export filter
ok_to_export() (su.c) and export() (login.c) read s[n] before
strncmp(s, *pp, n) confirms s is at least n bytes long, where n is
the length of the blocked variable name. A PAM environment entry
shorter than that name over-reads past its heap allocation.
Check strncmp() first; it stops at s's NUL terminator and never
reads past the boundary that guarded the s[n] access.
MFC after: 1 week
Sponsored by: Advanced Micro Devices, Inc.
Signed-off-by: Osvaldo Janeri Filho <ojanerif@amd.com>
Reviewed by: des, markj
Differential Revision: https://reviews.freebsd.org/D61420
(cherry picked from commit e1b5e1f9ddac43ed669a44cfdbba1b394d144c6b)
---
usr.bin/login/login.c | 2 +-
usr.bin/su/su.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c
index d0d4bb4a2394..cc62e50e4e0c 100644
--- a/usr.bin/login/login.c
+++ b/usr.bin/login/login.c
@@ -803,7 +803,7 @@ export(const char *s)
return (0);
for (pp = noexport; *pp != NULL; pp++) {
n = strlen(*pp);
- if (s[n] == '=' && strncmp(s, *pp, n) == 0)
+ if (strncmp(s, *pp, n) == 0 && s[n] == '=')
return (0);
}
*p = '\0';
diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c
index 3d97ab8deb30..1ce0e9b8fba9 100644
--- a/usr.bin/su/su.c
+++ b/usr.bin/su/su.c
@@ -599,7 +599,7 @@ ok_to_export(const char *s)
return 0;
for (pp = noexport; *pp != NULL; pp++) {
n = strlen(*pp);
- if (s[n] == '=' && strncmp(s, *pp, n) == 0)
+ if (strncmp(s, *pp, n) == 0 && s[n] == '=')
return 0;
}
return 1;