logo

skeud

Simple and portable utilities to deal with user accounts (su, login)
commit: 87a83ec16d0f2fe7eae80143c107ca9dd5042435
parent 2b28bce631481b27039e6952a8b1b76731ff9e37
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu,  3 Nov 2022 02:09:47 +0100

login,su: Prevent null pointer to setenv

Diffstat:

Mlogin.c5++++-
Msu.c5++++-
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/login.c b/login.c @@ -166,7 +166,10 @@ main(int argc, char *argv[]) { char *term = getenv("TERM"); environ = envclear; - setenv("TERM", term, 1); + if(term) + { + setenv("TERM", term, 1); + } } if(pwent != NULL) diff --git a/su.c b/su.c @@ -161,7 +161,10 @@ main(int argc, char *argv[]) { char *term = getenv("TERM"); environ = envclear; - setenv("TERM", term, 1); + if(term) + { + setenv("TERM", term, 1); + } } if(pwent != NULL)