projects
/
musl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
e5d2823
)
cuserid: support invocation with a null pointer argument
author
Sören Tempel
<soeren+git@soeren-tempel.net>
Wed, 29 Jan 2020 11:20:07 +0000
(12:20 +0100)
committer
Rich Felker
<dalias@aerifal.cx>
Sat, 13 Feb 2021 18:40:22 +0000
(13:40 -0500)
this function was removed from the standard in 2001 but appeared in
SUSv2 with an obligation to support calls with a null pointer
argument, using a static buffer.
src/legacy/cuserid.c
patch
|
blob
|
history
diff --git
a/src/legacy/cuserid.c
b/src/legacy/cuserid.c
index
4e78798
..
fd7832e
100644
(file)
--- a/
src/legacy/cuserid.c
+++ b/
src/legacy/cuserid.c
@@
-5,10
+5,12
@@
char *cuserid(char *buf)
{
+ static char usridbuf[L_cuserid];
struct passwd pw, *ppw;
long pwb[256];
if (getpwuid_r(geteuid(), &pw, (void *)pwb, sizeof pwb, &ppw))
return 0;
+ if (!buf) buf = usridbuf;
snprintf(buf, L_cuserid, "%s", pw.pw_name);
return buf;
}