]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Don't #undef stat and #define stat(). stat is one of those unfortunate 1076/head
authorJoel Uckelman <juckelman@strozfriedberg.co.uk>
Thu, 18 Oct 2018 15:02:47 +0000 (16:02 +0100)
committerJoel Uckelman <juckelman@strozfriedberg.co.uk>
Thu, 18 Oct 2018 15:25:14 +0000 (16:25 +0100)
identifiers for which there is both a struct and a function. MinGW uses
a #define for setting struct stat to be the right struct, so doing #undef
stat to clear the way for a #define for stat() the function
inadvertantly clobbers the selected stat struct. To avoid this, we
define la_stat() to _la_stat on Windows and stat() elsewhere, and then
use la_stat() instead of stat().

libarchive/archive_match.c
libarchive/archive_platform.h
libarchive/archive_read_disk_entry_from_file.c
libarchive/archive_read_disk_posix.c
libarchive/archive_util.c
libarchive/archive_windows.h
libarchive/archive_write_disk_posix.c

index f150e8224c1c402b16374a39c4daceeeb86ed34e..027d9715d4941da28479d0cdad4eab0fb7d1f8c4 100644 (file)
@@ -1232,7 +1232,7 @@ set_timefilter_pathname_mbs(struct archive_match *a, int timetype,
                archive_set_error(&(a->archive), EINVAL, "pathname is empty");
                return (ARCHIVE_FAILED);
        }
-       if (stat(path, &st) != 0) {
+       if (la_stat(path, &st) != 0) {
                archive_set_error(&(a->archive), errno, "Failed to stat()");
                return (ARCHIVE_FAILED);
        }
index 32b884c96ed3dfbc59cbc0b41115040bd4481924..b8bcb52bc90e911beb75ad21c21ec61016c69b6a 100644 (file)
@@ -69,6 +69,8 @@
  * either Windows or Posix APIs. */
 #if (defined(__WIN32__) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__)
 #include "archive_windows.h"
+#else
+#define la_stat(path,stref)            stat(path,stref)
 #endif
 
 /*
index 1786cff38453ce42c9346c5fedb33223f3443682..90d10bee9a47486ef6bfad9826908df39d5dd8d8 100644 (file)
@@ -188,7 +188,7 @@ archive_read_disk_entry_from_file(struct archive *_a,
                                }
                        } else
 #endif
-                       if (stat(path, &s) != 0) {
+                       if (la_stat(path, &s) != 0) {
                                archive_set_error(&a->archive, errno,
                                    "Can't stat %s", path);
                                return (ARCHIVE_FAILED);
index cdf7541238cf9fdc462226d1fc0af7bf226b2f7a..75aa54c7196285ece040e96f5c91d52b5f83acdb 100644 (file)
@@ -2450,7 +2450,7 @@ tree_current_stat(struct tree *t)
 #else
                if (tree_enter_working_dir(t) != 0)
                        return NULL;
-               if (stat(tree_current_access_path(t), &t->st) != 0)
+               if (la_stat(tree_current_access_path(t), &t->st) != 0)
 #endif
                        return NULL;
                t->flags |= hasStat;
index 96d61456d3398a56619c9d025d63c73442be78b8..3399c0b5f492e373362f7b626bbb60b54fe05a63 100644 (file)
@@ -449,7 +449,7 @@ __archive_mktemp(const char *tmpdir)
                temp_name.s[temp_name.length-1] = '\0';
                temp_name.length --;
        }
-       if (stat(temp_name.s, &st) < 0)
+       if (la_stat(temp_name.s, &st) < 0)
                goto exit_tmpfile;
        if (!S_ISDIR(st.st_mode)) {
                errno = ENOTDIR;
index e77cd08fc3b4062922336e1160241b9239ee8297..87d8c891bb0b2ed30bdb25c92b134e9e013753c0 100644 (file)
 #if !defined(__BORLANDC__) && !defined(__WATCOMC__)
 #define setmode                _setmode
 #endif
-#ifdef stat
-#undef stat
-#endif
-#define        stat(path,stref)                __la_stat(path,stref)
+#define        la_stat(path,stref)             __la_stat(path,stref)
 #if !defined(__WATCOMC__)
 #if !defined(__BORLANDC__)
 #define        strdup          _strdup
index 3fd5f57985149b238e2d8140b5eea52f51843649..7ae4becdd7de6e96de3e8732b53112cd04ce54f5 100644 (file)
@@ -2018,7 +2018,7 @@ restore_entry(struct archive_write_disk *a)
                 * follow the symlink if we're creating a dir.
                 */
                if (S_ISDIR(a->mode))
-                       r = stat(a->name, &a->st);
+                       r = la_stat(a->name, &a->st);
                /*
                 * If it's not a dir (or it's a broken symlink),
                 * then don't follow it.
@@ -2184,7 +2184,7 @@ create_filesystem_object(struct archive_write_disk *a)
 #ifdef HAVE_LSTAT
                        r = lstat(a->name, &st);
 #else
-                       r = stat(a->name, &st);
+                       r = la_stat(a->name, &st);
 #endif
                        if (r != 0)
                                r = errno;
@@ -2687,7 +2687,7 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
                                 * This is needed to extract hardlinks over
                                 * symlinks.
                                 */
-                               r = stat(head, &st);
+                               r = la_stat(head, &st);
                                if (r != 0) {
                                        tail[0] = c;
                                        if (errno == ENOENT) {
@@ -3027,7 +3027,7 @@ create_dir(struct archive_write_disk *a, char *path)
         * here loses the ability to extract through symlinks.  Also note
         * that this should not use the a->st cache.
         */
-       if (stat(path, &st) == 0) {
+       if (la_stat(path, &st) == 0) {
                if (S_ISDIR(st.st_mode))
                        return (ARCHIVE_OK);
                if ((a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE)) {
@@ -3085,7 +3085,7 @@ create_dir(struct archive_write_disk *a, char *path)
         * don't add it to the fixup list here, as it's already been
         * added.
         */
-       if (stat(path, &st) == 0 && S_ISDIR(st.st_mode))
+       if (la_stat(path, &st) == 0 && S_ISDIR(st.st_mode))
                return (ARCHIVE_OK);
 
        archive_set_error(&a->archive, errno, "Failed to create dir '%s'",