diff options
author | yar <yar@FreeBSD.org> | 2003-07-09 12:46:24 +0000 |
---|---|---|
committer | yar <yar@FreeBSD.org> | 2003-07-09 12:46:24 +0000 |
commit | 72eaf383f4c5fbe8c48c458e6f8e8633e63ea03d (patch) | |
tree | 7dc5f4feaf7be013a6d171a8d4a63d3048fbd9cc /libexec | |
parent | 9bee0009ad7da4c2d2844031401794cc57152e12 (diff) | |
download | FreeBSD-src-72eaf383f4c5fbe8c48c458e6f8e8633e63ea03d.zip FreeBSD-src-72eaf383f4c5fbe8c48c458e6f8e8633e63ea03d.tar.gz |
Make a malloced copy of "chrootdir" even if it points to an absolute
pathname inside "residue" so "chrootdir" can be simply freed later.
PR: bin/53435
Submitted by: Yutaka Ishihara <yutaka at fandc.co.jp>
MFC after: 1 week
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ftpd/ftpd.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 69353dc..31f9b2f 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1494,9 +1494,11 @@ skip: * c) expand it to the absolute pathname if necessary. */ if (dochroot && residue && - (chrootdir = strtok(residue, " \t")) != NULL && - chrootdir[0] != '/') { - asprintf(&chrootdir, "%s/%s", pw->pw_dir, chrootdir); + (chrootdir = strtok(residue, " \t")) != NULL) { + if (chrootdir[0] != '/') + asprintf(&chrootdir, "%s/%s", pw->pw_dir, chrootdir); + else + chrootdir = strdup(chrootdir); /* so it can be freed */ if (chrootdir == NULL) fatalerror("Ran out of memory."); } |