summaryrefslogtreecommitdiff
path: root/libarchive
diff options
context:
space:
mode:
authorJoel Uckelman <juckelman@strozfriedberg.co.uk>2022-06-30 14:12:43 +0100
committerJoel Uckelman <juckelman@strozfriedberg.co.uk>2022-06-30 14:14:05 +0100
commit4471283392192f9ad38fd3085f8d32dbd07d6126 (patch)
treeac2d0fc4db3223a11eee2b3105a7edf3d82363ba /libarchive
parenteb147233c252b97d81a39ce73111e3f416441765 (diff)
downloadlibarchive-4471283392192f9ad38fd3085f8d32dbd07d6126.tar.gz
Clean up the condition so we check EINVAL on Windows only.
Diffstat (limited to 'libarchive')
-rw-r--r--libarchive/archive_read_support_format_mtree.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c
index 3e797289..55f391cf 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;