diff options
author | Sven Weidauer <sven@5sw.de> | 2018-01-16 20:47:28 +0100 |
---|---|---|
committer | Sven Weidauer <sven@5sw.de> | 2018-01-16 20:47:28 +0100 |
commit | 7b4163e0216538823630113ed7534c319e19c385 (patch) | |
tree | fc495db2c19a94061be924d37ca50d2bb1b974e8 /utils/filename.c | |
parent | 40ae70a811c23b6ce0bf02a6ecbe9eab098ee52c (diff) | |
parent | c03405b3b3b28942d50f672e897be5cfc0f6c540 (diff) | |
download | netsurf-7b4163e0216538823630113ed7534c319e19c385.tar.gz netsurf-7b4163e0216538823630113ed7534c319e19c385.tar.bz2 |
Merge remote-tracking branch 'origin/master' into svenw/cocoa
Diffstat (limited to 'utils/filename.c')
-rw-r--r-- | utils/filename.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/utils/filename.c b/utils/filename.c index 01a403fd9..f0e1bb0f5 100644 --- a/utils/filename.c +++ b/utils/filename.c @@ -272,15 +272,19 @@ bool filename_flush_directory(const char *folder, int depth) parent = opendir(folder); while ((entry = readdir(parent))) { - struct stat statbuf; + int written; + struct stat statbuf; /* Ignore '.' and '..' */ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue; - snprintf(child, sizeof(child), "%s/%s", folder, entry->d_name); - child[sizeof(child) - 1] = '\0'; + written = snprintf(child, sizeof(child), "%s/%s", + folder, entry->d_name); + if (written == sizeof(child)) { + child[sizeof(child) - 1] = '\0'; + } if (stat(child, &statbuf) == -1) { NSLOG(netsurf, INFO, "Unable to stat %s: %s", child, @@ -383,16 +387,21 @@ bool filename_delete_recursive(char *folder) parent = opendir(folder); while ((entry = readdir(parent))) { + int written; + /* Ignore '.' and '..' */ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue; - snprintf(child, sizeof(child), "%s/%s", folder, entry->d_name); - child[sizeof(child) - 1] = '\0'; + written = snprintf(child, sizeof(child), "%s/%s", + folder, entry->d_name); + if (written == sizeof(child)) { + child[sizeof(child) - 1] = '\0'; + } if (stat(child, &statbuf) == -1) { - NSLOG(netsurf, INFO, "Unable to stat %s: %s", child, + NSLOG(netsurf, INFO, "Unable to stat %s: %s", child, strerror(errno)); continue; } |