summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-10 02:40:32 -0400
committerIan Moffett <ian@osmora.org>2025-07-10 02:40:32 -0400
commitcaae25854d3e93dbef5bab45cda9d52f82a94333 (patch)
treede28a1690f271c15a2c869b8d35641541e67e0bd /lib/libc
parent02e4990d05c881dfd0f40ca1e4d6d28879cfe9af (diff)
usr: libc: Duplicate cached username with strdup()
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/src/unistd/getlogin.c4
1 files 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;