mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-12 14:29:28 +00:00
Fix logxfer() by using realpath(3) instead of playing with getwd(3).
Previously logxfer() used to record bogus pathnames to the log in some cases, namely, when cwd was / or "name" was absolute. Noticed by: Nick Leuta MFC after: 2 weeks
This commit is contained in:
parent
f79bef6097
commit
8c1c21f2ef
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=137145
@ -3169,15 +3169,19 @@ setproctitle(const char *fmt, ...)
|
||||
static void
|
||||
logxfer(char *name, off_t size, time_t start)
|
||||
{
|
||||
char buf[1024];
|
||||
char buf[MAXPATHLEN + 1024];
|
||||
char path[MAXPATHLEN + 1];
|
||||
time_t now;
|
||||
|
||||
if (statfd >= 0 && getwd(path) != NULL) {
|
||||
if (statfd >= 0) {
|
||||
time(&now);
|
||||
snprintf(buf, sizeof(buf), "%.20s!%s!%s!%s/%s!%jd!%ld\n",
|
||||
if (realpath(name, path) == NULL) {
|
||||
syslog(LOG_NOTICE, "realpath failed on %s: %m", path);
|
||||
return;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%.20s!%s!%s!%s!%jd!%ld\n",
|
||||
ctime(&now)+4, ident, remotehost,
|
||||
path, name, (intmax_t)size,
|
||||
path, (intmax_t)size,
|
||||
(long)(now - start + (now == start)));
|
||||
write(statfd, buf, strlen(buf));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user