tftpd: Check for errors from chdir()

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Mark Johnston 2020-09-22 15:54:05 +00:00
parent 3994f5bc18
commit 0aabff2880

View File

@ -373,7 +373,10 @@ main(int argc, char *argv[])
chroot_dir, strerror(errno));
exit(1);
}
chdir("/");
if (chdir("/") != 0) {
tftp_log(LOG_ERR, "chdir: %s", strerror(errno));
exit(1);
}
if (setgroups(1, &nobody->pw_gid) != 0) {
tftp_log(LOG_ERR, "setgroups failed");
exit(1);