From b99161ec692c3ce476a3a10e59a2c49ae85f225e Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Mon, 5 Oct 1998 18:32:53 +0000 Subject: [PATCH] Add path_magic to work properly with #ftp:asdf files created by malicious user --- vfs/vfs.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/vfs/vfs.c b/vfs/vfs.c index 8f701e520..9d9062e69 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -60,12 +60,7 @@ extern int get_other_type (void); int vfs_timeout = 60; /* VFS timeout in seconds */ -int vfs_flags = /* Flags */ -#ifdef VFS_STANDALONE - 0; -#else - FL_ALWAYS_MAGIC; -#endif +int vfs_flags = 0; /* Flags */ extern int cd_symlinks; /* Defined in main.c */ @@ -141,11 +136,15 @@ vfs *vfs_type_from_op (char *path) int path_magic( char *path ) { int res; + struct stat buf; - res = !strncmp( path, "/#/", 3 ); - if (res) - path[1] = '/'; - return res || (vfs_flags & FL_ALWAYS_MAGIC); + if (vfs_flags & FL_ALWAYS_MAGIC) + return 1; + + if (!stat(path, &buf)) + return 0; + + return 1; } /* @@ -159,7 +158,7 @@ vfs *vfs_split (char *path, char **inpath, char **op) char *slash; vfs *ret; - if (!semi) + if (!semi || !path_magic(path)) return NULL; slash = strchr (semi, '/'); *semi = 0; @@ -190,7 +189,7 @@ vfs_rosplit (char *path) char *slash; vfs *ret; - if (!semi) + if (!semi || !path_magic(path)) return NULL; slash = strchr (semi, '/'); *semi = 0;