sfm

simple file manager
git clone git://git.afify.dev/sfm
Log | Files | Refs | README | LICENSE

commit b9d026726544ac0e95e942f61b5aa10b16deb0a7
parent aadc7c4c101dad3faf029a3afe9c27a37a590576
Author: afify <hassan@afify.dev>
Date:   Sat, 10 Apr 2021 02:24:47 +0300

[ref] mvbk() return if cwd is /

- replace strlen with strnlen
- early return if cwd is /

Diffstat:
Msfm.c | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/sfm.c b/sfm.c @@ -392,15 +392,14 @@ sort_name(const void *const A, const void *const B) } } - static void get_dirp(char *cdir) { int counter, len, i; counter = 0; - len = strlen(cdir); - if (len ==1) + len = strnlen(cdir, MAX_P); + if (len == 1) return; for (i = len - 1; i > 1; i--) { @@ -780,6 +779,10 @@ delfd(void) static void mvbk(void) { + if (cpane->dirn[0] == '/' && cpane->dirn[1] == '\0') { /* cwd = / */ + return; + } + get_dirp(cpane->dirn); if (check_dir(cpane->dirn) < 0) { print_error(strerror(errno));