summaryrefslogtreecommitdiffstats
path: root/libexec/ftpd
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2004-11-03 06:52:40 +0000
committeryar <yar@FreeBSD.org>2004-11-03 06:52:40 +0000
commit77ad2555a365853784da46e09b248ef963cc1210 (patch)
tree822990ebb1674c0b6b295886e723b1fdbc4a1cb4 /libexec/ftpd
parentcb7e4340514c332ef2b3ac808a06bb5470be16eb (diff)
downloadFreeBSD-src-77ad2555a365853784da46e09b248ef963cc1210.zip
FreeBSD-src-77ad2555a365853784da46e09b248ef963cc1210.tar.gz
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
Diffstat (limited to 'libexec/ftpd')
-rw-r--r--libexec/ftpd/ftpd.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index aeeaada..712f713 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -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));
}
OpenPOWER on IntegriCloud