From 4471283392192f9ad38fd3085f8d32dbd07d6126 Mon Sep 17 00:00:00 2001 From: Joel Uckelman Date: Thu, 30 Jun 2022 14:12:43 +0100 Subject: [PATCH] Clean up the condition so we check EINVAL on Windows only. --- libarchive/archive_read_support_format_mtree.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c index 3e797289e..55f391cff 100644 --- a/libarchive/archive_read_support_format_mtree.c +++ b/libarchive/archive_read_support_format_mtree.c @@ -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; -- 2.47.2