dir_remove() now handles a path which ends with "/./" and fixed #6817.
Another way would be to disallow removing such a path, as Linux does. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40819 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1075cc34a0
commit
8775d8d25d
@ -5813,22 +5813,22 @@ dir_remove(int fd, char* path, bool kernel)
|
||||
if (path != NULL) {
|
||||
// we need to make sure our path name doesn't stop with "/", ".",
|
||||
// or ".."
|
||||
char* lastSlash = strrchr(path, '/');
|
||||
if (lastSlash != NULL) {
|
||||
char* lastSlash;
|
||||
while ((lastSlash = strrchr(path, '/')) != NULL) {
|
||||
char* leaf = lastSlash + 1;
|
||||
if (!strcmp(leaf, ".."))
|
||||
return B_NOT_ALLOWED;
|
||||
|
||||
// omit multiple slashes
|
||||
while (lastSlash > path && lastSlash[-1] == '/') {
|
||||
while (lastSlash > path && lastSlash[-1] == '/')
|
||||
lastSlash--;
|
||||
}
|
||||
|
||||
if (!leaf[0]
|
||||
|| !strcmp(leaf, ".")) {
|
||||
// "name/" -> "name", or "name/." -> "name"
|
||||
lastSlash[0] = '\0';
|
||||
if (leaf[0]
|
||||
&& strcmp(leaf, ".")) {
|
||||
break;
|
||||
}
|
||||
// "name/" -> "name", or "name/." -> "name"
|
||||
lastSlash[0] = '\0';
|
||||
}
|
||||
|
||||
if (!strcmp(path, ".") || !strcmp(path, ".."))
|
||||
|
Loading…
Reference in New Issue
Block a user