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

Fixed buffer overflow when some directories can't be scanned

Also changed other occurences of the same situation to use the same
checking method (>= rather than a +1) for consistency.

Fixes bug #2981704.
parent 79733f7d
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ git - ? ...@@ -2,6 +2,7 @@ git - ?
- List the detected hard links in file info window - List the detected hard links in file info window
- Count the size a hard linked file once for each directory it appears in - Count the size a hard linked file once for each directory it appears in
- Fixed crash on browsing dirs with a small window size (#2991787) - Fixed crash on browsing dirs with a small window size (#2991787)
- Fixed buffer overflow when some directories can't be scanned (#2981704)
- Improved browsing performance - Improved browsing performance
- Various minor fixes - Various minor fixes
......
...@@ -247,7 +247,7 @@ int calc_dir(struct dir *dest, char *name) { ...@@ -247,7 +247,7 @@ int calc_dir(struct dir *dest, char *name) {
/* open & chdir into directory */ /* open & chdir into directory */
if((dir = opendir(name)) == NULL || chdir(name) < 0) { if((dir = opendir(name)) == NULL || chdir(name) < 0) {
if(lasterrl < (int)strlen(curpath)) { if(lasterrl <= (int)strlen(curpath)) {
lasterrl = strlen(curpath)+1; lasterrl = strlen(curpath)+1;
lasterr = realloc(lasterr, lasterrl); lasterr = realloc(lasterr, lasterrl);
} }
...@@ -465,7 +465,7 @@ int calc_process() { ...@@ -465,7 +465,7 @@ int calc_process() {
/* update curpath */ /* update curpath */
if(strcmp(name, ".")) { if(strcmp(name, ".")) {
if((int)strlen(path)+1 > curpathl) { if(curpathl <= (int)strlen(path)) {
curpathl = strlen(path)+1; curpathl = strlen(path)+1;
curpath = realloc(curpath, curpathl); curpath = realloc(curpath, curpathl);
} }
...@@ -532,7 +532,7 @@ void calc_init(char *dir, struct dir *org) { ...@@ -532,7 +532,7 @@ void calc_init(char *dir, struct dir *org) {
if(curpathl == 0) { if(curpathl == 0) {
curpathl = strlen(dir)+1; curpathl = strlen(dir)+1;
curpath = malloc(curpathl); curpath = malloc(curpathl);
} else if(curpathl < (int)strlen(dir)+1) { } else if(curpathl <= (int)strlen(dir)) {
curpathl = strlen(dir)+1; curpathl = strlen(dir)+1;
curpath = realloc(curpath, curpathl); curpath = realloc(curpath, curpathl);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment