diff options
author | billf <billf@FreeBSD.org> | 2003-04-19 10:14:43 +0000 |
---|---|---|
committer | billf <billf@FreeBSD.org> | 2003-04-19 10:14:43 +0000 |
commit | 614e371cc39f9a9c35f3c93d5eed3a619cc9c8e9 (patch) | |
tree | 548a72fce5e65a35f53c623f68c35e78aea1efa1 /libexec | |
parent | db4d21ffafbbfa6ff68e411a61e5cf3b8bcd7890 (diff) | |
download | FreeBSD-src-614e371cc39f9a9c35f3c93d5eed3a619cc9c8e9.zip FreeBSD-src-614e371cc39f9a9c35f3c93d5eed3a619cc9c8e9.tar.gz |
properly refuse a connection in the -c case if the client ip's subdirectory
does not exist.
PR: bin/38303
Submitted by: Woei-Luen, Shyu <m8535@cn.ee.ccu.edu.tw>
the committed patch differs from the submitted one, any inaccuracies are mine.
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/tftpd/tftpd.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c index 6eb3095..bc24753 100644 --- a/libexec/tftpd/tftpd.c +++ b/libexec/tftpd/tftpd.c @@ -171,7 +171,7 @@ main(int argc, char *argv[]) dirs->name = "/"; dirs->len = 1; } - if (ipchroot && chroot_dir == NULL) { + if (ipchroot > 0 && chroot_dir == NULL) { syslog(LOG_ERR, "-c requires -s"); exit(1); } @@ -245,7 +245,7 @@ main(int argc, char *argv[]) * be a problem. See the above comment about system clogging. */ if (chroot_dir) { - if (ipchroot) { + if (ipchroot > 0) { char *tempchroot; struct stat sb; int statret; @@ -258,9 +258,10 @@ main(int argc, char *argv[]) hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID); asprintf(&tempchroot, "%s/%s", chroot_dir, hbuf); - statret = stat(tempchroot, &sb); - if ((sb.st_mode & S_IFDIR) && - (statret == 0 || (statret == -1 && ipchroot == 1))) + if (ipchroot == 2) + statret = stat(tempchroot, &sb); + if (ipchroot == 1 || + (statret == 0 && (sb.st_mode & S_IFDIR))) chroot_dir = tempchroot; } /* Must get this before chroot because /etc might go away */ |