diff options
Diffstat (limited to 'src/legacy')
-rw-r--r-- | src/legacy/cuserid.c | 14 | ||||
-rw-r--r-- | src/legacy/ftw.c | 2 | ||||
-rw-r--r-- | src/legacy/lutimes.c | 12 |
3 files changed, 18 insertions, 10 deletions
diff --git a/src/legacy/cuserid.c b/src/legacy/cuserid.c index 4e78798d..dcaf73d4 100644 --- a/src/legacy/cuserid.c +++ b/src/legacy/cuserid.c @@ -2,13 +2,21 @@ #include <pwd.h> #include <stdio.h> #include <unistd.h> +#include <string.h> 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; - snprintf(buf, L_cuserid, "%s", pw.pw_name); + if (buf) *buf = 0; + getpwuid_r(geteuid(), &pw, (void *)pwb, sizeof pwb, &ppw); + if (!ppw) + return buf; + size_t len = strnlen(pw.pw_name, L_cuserid); + if (len == L_cuserid) + return buf; + if (!buf) buf = usridbuf; + memcpy(buf, pw.pw_name, len+1); return buf; } diff --git a/src/legacy/ftw.c b/src/legacy/ftw.c index 506bd29c..e757fc6f 100644 --- a/src/legacy/ftw.c +++ b/src/legacy/ftw.c @@ -7,5 +7,3 @@ int ftw(const char *path, int (*fn)(const char *, const struct stat *, int), int * actually undefined, but works on all real-world machines. */ return nftw(path, (int (*)())fn, fd_limit, FTW_PHYS); } - -weak_alias(ftw, ftw64); diff --git a/src/legacy/lutimes.c b/src/legacy/lutimes.c index 2e5502d1..dd465923 100644 --- a/src/legacy/lutimes.c +++ b/src/legacy/lutimes.c @@ -6,9 +6,11 @@ int lutimes(const char *filename, const struct timeval tv[2]) { struct timespec times[2]; - times[0].tv_sec = tv[0].tv_sec; - times[0].tv_nsec = tv[0].tv_usec * 1000; - times[1].tv_sec = tv[1].tv_sec; - times[1].tv_nsec = tv[1].tv_usec * 1000; - return utimensat(AT_FDCWD, filename, times, AT_SYMLINK_NOFOLLOW); + if (tv) { + times[0].tv_sec = tv[0].tv_sec; + times[0].tv_nsec = tv[0].tv_usec * 1000; + times[1].tv_sec = tv[1].tv_sec; + times[1].tv_nsec = tv[1].tv_usec * 1000; + } + return utimensat(AT_FDCWD, filename, tv ? times : 0, AT_SYMLINK_NOFOLLOW); } |