diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2019-08-15 19:55:16 +0100 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2019-08-15 20:23:12 +0100 |
commit | 5425a392951bca24bd32ea68f2abe6782af437f5 (patch) | |
tree | 70185fb6b555daf53059fbba4b68eb6c3953f93b | |
parent | 5d95a33ee50b26fd4bef814090a4e19572be1d78 (diff) | |
download | imv-5425a392951bca24bd32ea68f2abe6782af437f5.tar.gz |
imv_navigator_add: Check stat() return code
-rw-r--r-- | src/navigator.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/navigator.c b/src/navigator.c index 6d38c4d..98c1976 100644 --- a/src/navigator.c +++ b/src/navigator.c @@ -73,7 +73,9 @@ int imv_navigator_add(struct imv_navigator *nav, const char *path, { char path_buf[PATH_MAX+1]; struct stat path_info; - stat(path, &path_info); + if (stat(path, &path_info)) { + return 1; + } if (S_ISDIR(path_info.st_mode)) { int result = 0; DIR *d = opendir(path); @@ -85,7 +87,10 @@ int imv_navigator_add(struct imv_navigator *nav, const char *path, } snprintf(path_buf, sizeof path_buf, "%s/%s", path, dir->d_name); struct stat new_path_info; - stat(path_buf, &new_path_info); + if (stat(path_buf, &new_path_info)) { + result = 1; + break; + } int is_dir = S_ISDIR(new_path_info.st_mode); if (is_dir && recursive) { if (imv_navigator_add(nav, path_buf, recursive) != 0) { |