summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/firejail/util.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/firejail/util.c b/src/firejail/util.c
index a737f9d47..4634993df 100644
--- a/src/firejail/util.c
+++ b/src/firejail/util.c
@@ -1163,7 +1163,7 @@ int safe_fd(const char *path, int flags) {
1163 return parentfd; 1163 return parentfd;
1164 } 1164 }
1165 1165
1166 while (tok) { 1166 while(1) {
1167 // open the element, assuming it is a directory; this fails with ENOTDIR if it is a symbolic link 1167 // open the element, assuming it is a directory; this fails with ENOTDIR if it is a symbolic link
1168 // if token is a single dot, the previous directory is reopened 1168 // if token is a single dot, the previous directory is reopened
1169 fd = openat(parentfd, tok, O_PATH|O_DIRECTORY|O_NOFOLLOW|O_CLOEXEC); 1169 fd = openat(parentfd, tok, O_PATH|O_DIRECTORY|O_NOFOLLOW|O_CLOEXEC);
@@ -1181,10 +1181,10 @@ int safe_fd(const char *path, int flags) {
1181 // move on to next path segment 1181 // move on to next path segment
1182 last_tok = tok; 1182 last_tok = tok;
1183 tok = strtok(NULL, "/"); 1183 tok = strtok(NULL, "/");
1184 if (tok) { 1184 if (!tok)
1185 close(parentfd); 1185 break;
1186 parentfd = fd; 1186 close(parentfd);
1187 } 1187 parentfd = fd;
1188 } 1188 }
1189 1189
1190 // we are here because the last path element exists and is of file type directory 1190 // we are here because the last path element exists and is of file type directory