From caae25854d3e93dbef5bab45cda9d52f82a94333 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 10 Jul 2025 02:40:32 -0400 Subject: usr: libc: Duplicate cached username with strdup() Signed-off-by: Ian Moffett --- lib/libc/src/unistd/getlogin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libc/src/unistd/getlogin.c b/lib/libc/src/unistd/getlogin.c index 91f326c..dd74261 100644 --- a/lib/libc/src/unistd/getlogin.c +++ b/lib/libc/src/unistd/getlogin.c @@ -41,7 +41,7 @@ static int match_entry(uid_t uid, char *entry) { char uidstr[16]; - static char *username = NULL; + char *username = NULL; char *p; size_t len; uint8_t row = 0; @@ -66,7 +66,7 @@ match_entry(uid_t uid, char *entry) * username. */ if (strcmp(uidstr, p) == 0) { - ucache = username; + ucache = strdup(username); return 0; } break; -- cgit v1.2.3