Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix realpath usage.
Vsevolod Stakhov committed 11 years ago
commit 10923e0a55ae03313e54df6317a2486666f5a1a4
parent 3eb77bb
1 file changed +5 -4
modified libpkg/ssh.c
@@ -131,14 +131,15 @@ pkg_sshserve(int fd)
		if (restricted != NULL) {
#endif
			chdir(restricted);
-
			file = realpath(file, fpath);
-
			if (strncmp(file, restricted, strlen(restricted)) != 0) {
+

+
			if (realpath(file, fpath) == NULL ||
+
					strncmp(file, restricted, strlen(restricted)) != 0) {
				printf("ko: file not found\n");
				continue;
			}
		}

-
		if (fstatat(fd, file, &st, 0) == -1) {
+
		if (fstatat(fd, fpath, &st, 0) == -1) {
			pkg_debug(1, "SSH server> fstatat failed");
			printf("ko: file not found\n");
			continue;
@@ -154,7 +155,7 @@ pkg_sshserve(int fd)
			continue;
		}

-
		if ((ffd = openat(fd, file, O_RDONLY)) == -1) {
+
		if ((ffd = openat(fd, fpath, O_RDONLY)) == -1) {
			printf("ko: file not found\n");
			continue;
		}