diff --git a/lib/libarchive/archive_read_extract.c b/lib/libarchive/archive_read_extract.c index 9e851bb3ef1b..cde42b86db2b 100644 --- a/lib/libarchive/archive_read_extract.c +++ b/lib/libarchive/archive_read_extract.c @@ -1054,10 +1054,13 @@ set_perm(struct archive *a, int fd, struct archive_entry *entry, */ if (!S_ISLNK(archive_entry_mode(entry))) { #ifdef HAVE_FCHMOD - if (fd >= 0 && fchmod(fd, mode) != 0) { - archive_set_error(a, errno, "Can't set permissions"); - return (ARCHIVE_WARN); - } + if (fd >= 0) { + if (fchmod(fd, mode) != 0) { + archive_set_error(a, errno, + "Can't set permissions"); + return (ARCHIVE_WARN); + } + } else #endif if (chmod(name, mode) != 0) { archive_set_error(a, errno, "Can't set permissions");