Skip to content

Commit 0d84172

Browse files
author
Jamie C. Driver
committed
usbstorage: hide files where the name begins with a '.'
1 parent 8c7f550 commit 0d84172

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

main/usbhmsc/usbmode.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,19 @@ static bool select_file_from_filtered_list(const char* title, const char* const
153153

154154
// DT_REG: regular file
155155
if (entry->d_type == DT_REG) {
156+
JADE_ASSERT(entry->d_name);
156157
const size_t d_name_len = strlen(entry->d_name);
157158
if (path_len + 1 + d_name_len + 1 > MAX_FILENAME_SIZE) {
158159
// We don't support overlong filenames - skip
159160
continue;
160161
}
161162

163+
// Skip files where the name begins with a '.'
164+
if (entry->d_name[0] == '.') {
165+
// Treat as a hidden file and do not show
166+
continue;
167+
}
168+
162169
// Offer to filter function
163170
if (!filter(path, entry->d_name, d_name_len)) {
164171
// Does not pass filter - skip
@@ -675,7 +682,7 @@ static bool is_full_fw_file(const char* path, const char* filename, const size_t
675682

676683
// Must have corresponding hash file
677684
char hash_filename[MAX_FILENAME_SIZE];
678-
if (strlen(path) + 1 + filename_len + sizeof(HASH_SUFFIX) + 1 > sizeof(hash_filename)) {
685+
if (strlen(path) + 1 + filename_len + strlen(HASH_SUFFIX) + 1 > sizeof(hash_filename)) {
679686
return false;
680687
}
681688
const int ret = snprintf(hash_filename, sizeof(hash_filename), "%s/%s%s", path, filename, HASH_SUFFIX);

0 commit comments

Comments
 (0)