Skip to content
Snippets Groups Projects
Commit 3dc21365 authored by Yorhel's avatar Yorhel
Browse files

Fixed another PATH_MAX reliance in calc.c

Make sure not to pass the absolute root directory to lstat() and
chdir(), as these functions can't handle long path names.
parent c432928b
No related branches found
No related tags found
No related merge requests found
...@@ -140,7 +140,7 @@ int calc_item(struct dir *par, char *name) { ...@@ -140,7 +140,7 @@ int calc_item(struct dir *par, char *name) {
/* recursively walk through the directory tree, /* recursively walk through the directory tree,
assumes path resides in the cwd */ assumes path resides in the cwd */
int calc_dir(struct dir *dest) { int calc_dir(struct dir *dest, char *name) {
struct dir *t; struct dir *t;
DIR *dir; DIR *dir;
char *tmp; char *tmp;
...@@ -151,7 +151,7 @@ int calc_dir(struct dir *dest) { ...@@ -151,7 +151,7 @@ int calc_dir(struct dir *dest) {
return 1; return 1;
/* open directory */ /* open directory */
if((dir = opendir(dest->name)) == NULL) { if((dir = opendir(name)) == NULL) {
tmp = getpath(dest); tmp = getpath(dest);
if(lasterrl < (int)strlen(tmp)+1) { if(lasterrl < (int)strlen(tmp)+1) {
lasterrl = strlen(tmp)+1; lasterrl = strlen(tmp)+1;
...@@ -166,7 +166,7 @@ int calc_dir(struct dir *dest) { ...@@ -166,7 +166,7 @@ int calc_dir(struct dir *dest) {
} }
/* chdir */ /* chdir */
if(chdir(dest->name) < 0) { if(chdir(name) < 0) {
dest->flags |= FF_ERR; dest->flags |= FF_ERR;
return 0; return 0;
} }
...@@ -200,7 +200,7 @@ int calc_dir(struct dir *dest) { ...@@ -200,7 +200,7 @@ int calc_dir(struct dir *dest) {
ch = 0; ch = 0;
for(t=dest->sub; t!=NULL; t=t->next) for(t=dest->sub; t!=NULL; t=t->next)
if(t->flags & FF_DIR && !(t->flags & FF_EXL || t->flags & FF_OTHFS)) if(t->flags & FF_DIR && !(t->flags & FF_EXL || t->flags & FF_OTHFS))
if(calc_dir(t)) if(calc_dir(t, t->name))
return 1; return 1;
/* chdir back */ /* chdir back */
...@@ -345,7 +345,7 @@ void calc_process() { ...@@ -345,7 +345,7 @@ void calc_process() {
free(path); free(path);
/* start calculating */ /* start calculating */
if(!calc_dir(root) && !failed) { if(!calc_dir(root, name) && !failed) {
browse_init(root->sub); browse_init(root->sub);
/* update references and free original item */ /* update references and free original item */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment