diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-05-31 16:21:54 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-05-31 16:21:54 -0400 |
commit | dff73d26f3a6c9d7011ad98a6752129a37625a10 (patch) | |
tree | 6fdf63be0e3331f098675bf694333672b699f7f1 | |
parent | fc0842275de8f8ab43374df922907d97b4e60b58 (diff) | |
parent | b86c562d76c7b0cce25a3a9f46d5d66e2eef30ff (diff) | |
download | tor-dff73d26f3a6c9d7011ad98a6752129a37625a10.tar.gz tor-dff73d26f3a6c9d7011ad98a6752129a37625a10.zip |
Merge remote-tracking branch 'public/bug5089'
Conflicts:
src/test/test_util.c
Merge the unit tests; I added some when I did this branch against
0.2.2, and then the test format changed and master added more tests.
-rw-r--r-- | changes/bug5089 | 5 | ||||
-rw-r--r-- | src/common/compat.c | 13 | ||||
-rw-r--r-- | src/test/test_util.c | 16 |
3 files changed, 22 insertions, 12 deletions
diff --git a/changes/bug5089 b/changes/bug5089 new file mode 100644 index 0000000000..2062885af7 --- /dev/null +++ b/changes/bug5089 @@ -0,0 +1,5 @@ + o Minor bugfixes: + - Correctly handle checking the permissions on the parent + directory of a control socket in the root directory. Bug found + by Esteban Manchado Velázquez. Fix for bug 5089; bugfix on Tor + 0.2.2.26-beta. diff --git a/src/common/compat.c b/src/common/compat.c index 59c7ca4c5a..093106120d 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -1656,7 +1656,11 @@ get_user_homedir(const char *username) } #endif -/** Modify <b>fname</b> to contain the name of the directory */ +/** Modify <b>fname</b> to contain the name of its parent directory. Doesn't + * actually examine the filesystem; does a purely syntactic modification. + * + * The parent of the root director is considered to be iteself. + * */ int get_parent_directory(char *fname) { @@ -1678,13 +1682,18 @@ get_parent_directory(char *fname) */ cp = fname + strlen(fname); at_end = 1; - while (--cp > fname) { + while (--cp >= fname) { int is_sep = (*cp == '/' #ifdef _WIN32 || *cp == '\\' #endif ); if (is_sep) { + if (cp == fname) { + /* This is the first separator in the file name; don't remove it! */ + cp[1] = '\0'; + return 0; + } *cp = '\0'; if (! at_end) return 0; diff --git a/src/test/test_util.c b/src/test/test_util.c index 99c5544508..e05269252b 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -2084,10 +2084,8 @@ test_util_parent_dir(void *ptr) T("/home/wombat", 0, "/home/wombat/knish/"); T("/home/wombat", 0, "/home/wombat/knish///"); T("./home/wombat", 0, "./home/wombat/knish/"); -#if 0 T("/", 0, "/home"); T("/", 0, "/home//"); -#endif T(".", 0, "./wombat"); T(".", 0, "./wombat/"); T(".", 0, "./wombat//"); @@ -2101,14 +2099,12 @@ test_util_parent_dir(void *ptr) T("wombat", 0, "wombat/.foo"); T("wombat", 0, "wombat/.foo/"); - T("", -1, ""); - T("", -1, "."); - T("", -1, ".."); - T("", -1, "../"); - T("", -1, "/"); - T("", -1, "////"); - T("", -1, "wombat"); - T("", -1, "wombat/"); + T("wombat", -1, ""); + T("w", -1, ""); + T("wombat", 0, "wombat/knish"); + + T("/", 0, "/"); + T("/", 0, "////"); done: tor_free(cp); |