diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2005-09-29 16:23:22 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2005-09-29 16:23:22 +0000 |
commit | f6c9ff6646a97ad4dd45ebdf755d4eb73fe5b6a5 (patch) | |
tree | ad572005626fe141e487dc98b783921d9d0d3854 /winsup/cygwin/path.cc | |
parent | 9a7b0aad2ade1e0f3d0450118861d7bc52f344c0 (diff) | |
download | cygnal-f6c9ff6646a97ad4dd45ebdf755d4eb73fe5b6a5.tar.gz cygnal-f6c9ff6646a97ad4dd45ebdf755d4eb73fe5b6a5.tar.bz2 cygnal-f6c9ff6646a97ad4dd45ebdf755d4eb73fe5b6a5.zip |
* dir.cc (mkdir): Check for trailing /. or /.. component.
(rmdir): Ditto.
* path.cc (has_dot_last_component): New function.
* path.h (has_dot_last_component): Add declaration.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r-- | winsup/cygwin/path.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 6b1e44cbd..c948eecf7 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -205,6 +205,24 @@ pathmatch (const char *path1, const char *path2) : strcasematch (path1, path2); } +/* TODO: This function is used in mkdir and rmdir to generate correct + error messages in case of paths ending in /. or /.. components. + This test should eventually end up in path_conv::check in one way + or another. Right now, normalize_posix_path will just normalize + those components away, which changes the semantics. */ +bool +has_dot_last_component (const char *dir) +{ + /* SUSv3: . and .. are not allowed as last components in various system + calls. Don't test for backslash path separator since that's a Win32 + path following Win32 rules. */ + const char *last_comp = strrchr (dir, '/'); + return last_comp + && last_comp[1] == '.' + && (last_comp[2] == '\0' + || (last_comp[2] == '.' && last_comp[3] == '\0')); +} + #define isslash(c) ((c) == '/') /* Normalize a POSIX path. |