]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
unzip: use lchmod() and optreset only if available (fix Android build)
authorMartin Matuska <martin@matuska.de>
Tue, 18 Jul 2023 13:41:43 +0000 (15:41 +0200)
committerMartin Matuska <martin@matuska.de>
Tue, 18 Jul 2023 13:42:14 +0000 (15:42 +0200)
Fixes #1921

unzip/bsdunzip.c

index 469c69fd6efb95f4b110783ecace8724d2bbbb5c..7a3758f6acb998d3ec235e07b1c266b22236655d 100644 (file)
@@ -694,8 +694,10 @@ recheck:
                if (symlink(linkname, *path) != 0)
                        error("symlink('%s')", *path);
                info(" extracting: %s -> %s\n", *path, linkname);
+#ifdef HAVE_LCHMOD
                if (lchmod(*path, mode) != 0)
                        warning("Cannot set mode for '%s'", *path);
+#endif
                /* set access and modification time */
                if (utimensat(AT_FDCWD, *path, ts, AT_SYMLINK_NOFOLLOW) != 0)
                        warning("utimensat('%s')", *path);
@@ -1053,7 +1055,10 @@ getopts(int argc, char *argv[])
 {
        int opt;
 
-       optreset = optind = 1;
+       optind = 1;
+#ifdef HAVE_GETOPT_OPTRESET
+       optreset = 1;
+#endif
        while ((opt = getopt(argc, argv, "aCcd:fjLlnopP:qtuvx:yZ1")) != -1)
                switch (opt) {
                case '1':