]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Do not use deprecated readdir_r() on glibc 2.24 and later 775/head
authorMartin Matuska <martin@matuska.org>
Sun, 28 Aug 2016 01:04:17 +0000 (03:04 +0200)
committerMartin Matuska <martin@matuska.org>
Sun, 28 Aug 2016 10:04:26 +0000 (12:04 +0200)
libarchive/archive_platform.h
libarchive/archive_read_disk_posix.c

index b06c3cd28fa6d98c8e3c0583dd90d00df382d524..e44c93277cf838c0dfc03d9e1c9ace37f77df075 100644 (file)
 #define        CAN_RESTORE_METADATA_FD
 #endif
 
+/*
+ * glibc 2.24 deprecates readdir_r
+ */
+#if defined(HAVE_READDIR_R) && (!defined(__GLIBC__) || !defined(__GLIBC_MINOR__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24))
+#define        USE_READDIR_R   1
+#else
+#undef USE_READDIR_R
+#endif
+
 /* Set up defaults for internal error codes. */
 #ifndef ARCHIVE_ERRNO_FILE_FORMAT
 #if HAVE_EFTYPE
index 5901a879c4973c9870363e7354da423193ef5313..56b3a93e8f120570c26e987875d83f5d03b1541a 100644 (file)
@@ -165,7 +165,7 @@ struct filesystem {
        int             synthetic;
        int             remote;
        int             noatime;
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        size_t          name_max;
 #endif
        long            incr_xfer_size;
@@ -200,7 +200,7 @@ struct tree {
        DIR                     *d;
 #define        INVALID_DIR_HANDLE NULL
        struct dirent           *de;
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        struct dirent           *dirent;
        size_t                   dirent_allocated;
 #endif
@@ -1583,7 +1583,7 @@ setup_current_filesystem(struct archive_read_disk *a)
 #endif
                t->current_filesystem->noatime = 0;
 
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        /* Set maximum filename length. */
 #if defined(HAVE_STRUCT_STATFS_F_NAMEMAX)
        t->current_filesystem->name_max = sfs.f_namemax;
@@ -1606,7 +1606,7 @@ setup_current_filesystem(struct archive_read_disk *a)
        else
                t->current_filesystem->name_max = nm;
 #endif
-#endif /* HAVE_READDIR_R */
+#endif /* USE_READDIR_R */
        return (ARCHIVE_OK);
 }
 
@@ -1808,7 +1808,7 @@ setup_current_filesystem(struct archive_read_disk *a)
 #endif
                t->current_filesystem->noatime = 0;
 
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        /* Set maximum filename length. */
        t->current_filesystem->name_max = sfs.f_namelen;
 #endif
@@ -1892,7 +1892,7 @@ setup_current_filesystem(struct archive_read_disk *a)
 #endif
                t->current_filesystem->noatime = 0;
 
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        /* Set maximum filename length. */
        t->current_filesystem->name_max = sfs.f_namemax;
 #endif
@@ -1909,7 +1909,7 @@ static int
 setup_current_filesystem(struct archive_read_disk *a)
 {
        struct tree *t = a->tree;
-#if defined(_PC_NAME_MAX) && defined(HAVE_READDIR_R)
+#if defined(_PC_NAME_MAX) && defined(USE_READDIR_R)
        long nm;
 #endif
        t->current_filesystem->synthetic = -1;/* Not supported */
@@ -1921,7 +1921,7 @@ setup_current_filesystem(struct archive_read_disk *a)
        t->current_filesystem->min_xfer_size = -1;
        t->current_filesystem->incr_xfer_size = -1;
 
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        /* Set maximum filename length. */
 #  if defined(_PC_NAME_MAX)
        if (tree_current_is_symblic_link_target(t)) {
@@ -1949,7 +1949,7 @@ setup_current_filesystem(struct archive_read_disk *a)
        else
                t->current_filesystem->name_max = nm;
 #  endif /* _PC_NAME_MAX */
-#endif /* HAVE_READDIR_R */
+#endif /* USE_READDIR_R */
        return (ARCHIVE_OK);
 }
 
@@ -2357,7 +2357,7 @@ tree_dir_next_posix(struct tree *t)
        size_t namelen;
 
        if (t->d == NULL) {
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
                size_t dirent_size;
 #endif
 
@@ -2378,7 +2378,7 @@ tree_dir_next_posix(struct tree *t)
                        t->visit_type = r != 0 ? r : TREE_ERROR_DIR;
                        return (t->visit_type);
                }
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
                dirent_size = offsetof(struct dirent, d_name) +
                  t->filesystem_table[t->current->filesystem_id].name_max + 1;
                if (t->dirent == NULL || t->dirent_allocated < dirent_size) {
@@ -2395,11 +2395,11 @@ tree_dir_next_posix(struct tree *t)
                        }
                        t->dirent_allocated = dirent_size;
                }
-#endif /* HAVE_READDIR_R */
+#endif /* USE_READDIR_R */
        }
        for (;;) {
                errno = 0;
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
                r = readdir_r(t->d, t->dirent, &t->de);
 #ifdef _AIX
                /* Note: According to the man page, return value 9 indicates
@@ -2651,7 +2651,7 @@ tree_free(struct tree *t)
        if (t == NULL)
                return;
        archive_string_free(&t->path);
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        free(t->dirent);
 #endif
        free(t->sparse_list);