From 7780bec7b4169cb2a78ceda16e6dc9e00dcb0b0f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 25 Oct 2004 06:23:28 +0000 Subject: r3198: check for too many .. components in filenames pvfs now passes RAW-MKDIR (This used to be commit 41adb385f123b8d4cd3fe2eb03d891b6bdcf2361) --- source4/ntvfs/posix/pvfs_resolve.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source4/ntvfs/posix/pvfs_resolve.c') diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c index 5b86cd3a73..5d98274511 100644 --- a/source4/ntvfs/posix/pvfs_resolve.c +++ b/source4/ntvfs/posix/pvfs_resolve.c @@ -180,8 +180,9 @@ static NTSTATUS pvfs_case_search(struct pvfs_state *pvfs, struct pvfs_filename * static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name, uint_t flags, struct pvfs_filename *name) { - char *ret, *p; + char *ret, *p, *p_start; size_t len; + int num_components=0; name->original_name = talloc_strdup(name, cifs_name); name->stream_name = NULL; @@ -217,6 +218,7 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name, /* now do an in-place conversion of '\' to '/', checking for legal characters */ + p_start = p; while (*p) { size_t c_size; codepoint_t c = next_codepoint(p, &c_size); @@ -228,6 +230,7 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name, return NT_STATUS_ILLEGAL_CHARACTER; } *p = '/'; + num_components++; break; case ':': if (!(flags & PVFS_RESOLVE_STREAMS)) { @@ -252,6 +255,18 @@ static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name, case '/': case '|': return NT_STATUS_ILLEGAL_CHARACTER; + case '.': + if (p[1] != '.' || + (p[2] != '\\' && p[2] != 0) || + (p != p_start && p[-1] != '/')) { + break; + } + /* its definately a .. component */ + num_components--; + if (num_components <= 0) { + return NT_STATUS_OBJECT_PATH_SYNTAX_BAD; + } + break; } p += c_size; -- cgit