Skip to content

Commit

Permalink
Clean up the condition so we check EINVAL on Windows only.
Browse files Browse the repository at this point in the history
  • Loading branch information
uckelman-sf committed Jun 30, 2022
1 parent eb14723 commit 4471283
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions libarchive/archive_read_support_format_mtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1250,12 +1250,17 @@ parse_file(struct archive_read *a, struct archive_entry *entry,
archive_entry_filetype(entry) == AE_IFDIR) {
mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC);
__archive_ensure_cloexec_flag(mtree->fd);
if (mtree->fd == -1 &&
/* On Windows, attempting to open a file with an invalid name
* result in EINVAL (Error 22)
*/
((errno != ENOENT && errno != EINVAL) ||
archive_strlen(&mtree->contents_name) > 0)) {
if (mtree->fd == -1 && (
#if defined(_WIN32) && !defined(__CYGWIN__)
/*
* On Windows, attempting to open a file with an
* invalid name result in EINVAL (Error 22)
*/
(errno != ENOENT && errno != EINVAL)
#else
errno != ENOENT
#endif
|| archive_strlen(&mtree->contents_name) > 0)) {
archive_set_error(&a->archive, errno,
"Can't open %s", path);
r = ARCHIVE_WARN;
Expand Down

0 comments on commit 4471283

Please sign in to comment.