diff options
author | 2016-04-10 15:47:51 +1000 | |
---|---|---|
committer | 2016-04-10 15:47:51 +1000 | |
commit | d74f5db8130e17d771155b1bc17dc6fb4489ae04 (patch) | |
tree | f24e74e1ce0a40059bf08a7a4a355e9113446fc4 | |
parent | 760b4bd93b82d4219f5a084bc8553a4b283e0733 (diff) |
Fix for archives containing directories like foobar following foo
-rw-r--r-- | src/lib/util/zippath.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/util/zippath.cpp b/src/lib/util/zippath.cpp index c2d7ed0f022..d065d108e3e 100644 --- a/src/lib/util/zippath.cpp +++ b/src/lib/util/zippath.cpp @@ -942,10 +942,10 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory) { result = osd_readdir(directory->directory); } - while((result != nullptr) && (!strcmp(result->name, ".") || !strcmp(result->name, ".."))); + while (result && (!strcmp(result->name, ".") || !strcmp(result->name, ".."))); /* special case - is this entry a ZIP file? if so we need to return it as a "directory" */ - if ((result != nullptr) && (is_zip_file(result->name) || is_7z_file(result->name))) + if (result && (is_zip_file(result->name) || is_7z_file(result->name))) { /* copy; but change the entry type */ directory->returned_entry = *result; @@ -977,10 +977,11 @@ const osd_directory_entry *zippath_readdir(zippath_directory *directory) if (*separator || directory->zipfile->current_is_directory()) { /* a nested entry; loop through returned_dirlist to see if we've returned the parent directory */ + auto const len(separator - relpath); zippath_returned_directory *rdent; for (rdent = directory->returned_dirlist; rdent != nullptr; rdent = rdent->next) { - if (!core_strnicmp(rdent->name.c_str(), relpath, separator - relpath + 1)) + if ((rdent->name.length() == len) && !core_strnicmp(rdent->name.c_str(), relpath, len)) break; } |