summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-02-11 22:32:47 +1100
committerEmil Velikov <[email protected]>2017-02-13 10:01:12 +0000
commit0cbde643eb29c8bf19eb8551ac8e821f7f733212 (patch)
treeff92b236cebd2654d4bb232a38d20419afd21e5b /src
parent0f53404565b9ef9da9d7022b5732463acd496742 (diff)
util/disk_cache: correctly use stat(3)
I forgot to error check stat() and also I wasn't using the subdir in is_two_character_sub_directory(). Fixes: d7b3707c612 "util/disk_cache: use stat() to check if entry is a directory" Reviewed-by: Plamena Manolova <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/util/disk_cache.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 42fe432b8c4..047a016006b 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -445,10 +445,10 @@ is_regular_non_tmp_file(struct dirent *entry, const char *path)
return false;
struct stat sb;
- stat(filename, &sb);
+ int res = stat(filename, &sb);
free(filename);
- if (!S_ISREG(sb.st_mode))
+ if (res == -1 || !S_ISREG(sb.st_mode))
return false;
size_t len = strlen (entry->d_name);
@@ -492,10 +492,10 @@ is_two_character_sub_directory(struct dirent *entry, const char *path)
return false;
struct stat sb;
- stat(path, &sb);
+ int res = stat(subdir, &sb);
free(subdir);
- if (!S_ISDIR(sb.st_mode))
+ if (res == -1 || !S_ISDIR(sb.st_mode))
return false;
if (strlen(entry->d_name) != 2)