]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Clean up the condition so we check EINVAL on Windows only. 1736/head
authorJoel Uckelman <juckelman@strozfriedberg.co.uk>
Thu, 30 Jun 2022 13:12:43 +0000 (14:12 +0100)
committerJoel Uckelman <juckelman@strozfriedberg.co.uk>
Thu, 30 Jun 2022 13:14:05 +0000 (14:14 +0100)
libarchive/archive_read_support_format_mtree.c

index 3e797289eed2ab6e4d216c3b7e7a78af242a6648..55f391cff090707b4ff39c2be69adfc06ef8c4c7 100644 (file)
@@ -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;