summaryrefslogtreecommitdiffstats
path: root/l
diff options
context:
space:
mode:
authorAdrien Nader <adrien@notk.org>2014-11-01 20:06:54 +0100
committerAdrien Nader <adrien@notk.org>2014-11-01 20:06:54 +0100
commit8a7cc46ba5a1c6ba784fab213a6c6762e35fa692 (patch)
treef5a5f7c70f62b1484d28c8ba1b6add57353aa7f5 /l
parent0beeaa31a51fc7dbe8c16d11444e36f5a60719b1 (diff)
libarchive: ensure 64-bit "struct stat" is used.
Diffstat (limited to 'l')
-rw-r--r--l/libarchive/0001-windows-don-t-undef-stat-since-it-my-be-defined-to-s.patch90
-rwxr-xr-xl/libarchive/libarchive.SlackBuild5
-rw-r--r--l/libarchive/use-static-asserts-to-guarantee-abi-compatibility.patch26
3 files changed, 120 insertions, 1 deletions
diff --git a/l/libarchive/0001-windows-don-t-undef-stat-since-it-my-be-defined-to-s.patch b/l/libarchive/0001-windows-don-t-undef-stat-since-it-my-be-defined-to-s.patch
new file mode 100644
index 0000000..731b717
--- /dev/null
+++ b/l/libarchive/0001-windows-don-t-undef-stat-since-it-my-be-defined-to-s.patch
@@ -0,0 +1,90 @@
+From 520c62fbfca6173d9481e9e26a21946a0d519284 Mon Sep 17 00:00:00 2001
+From: Adrien Nader <adrien@notk.org>
+Date: Fri, 31 Oct 2014 09:17:26 +0100
+Subject: [PATCH] windows: don't #undef stat since it my be defined to
+ "stat64".
+
+---
+ libarchive/archive_match.c | 2 +-
+ libarchive/archive_platform.h | 2 ++
+ libarchive/archive_read_disk_entry_from_file.c | 2 +-
+ libarchive/archive_util.c | 2 +-
+ libarchive/archive_windows.h | 10 ++++++----
+ 5 files changed, 11 insertions(+), 7 deletions(-)
+
+diff --git a/libarchive/archive_match.c b/libarchive/archive_match.c
+index 6b6be9c..0dcb5e3 100644
+--- a/libarchive/archive_match.c
++++ b/libarchive/archive_match.c
+@@ -1227,7 +1227,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 (my_stat(path, &st) != 0) {
+ archive_set_error(&(a->archive), errno, "Failed to stat()");
+ return (ARCHIVE_FAILED);
+ }
+diff --git a/libarchive/archive_platform.h b/libarchive/archive_platform.h
+index ce2f482..e9ec5a4 100644
+--- a/libarchive/archive_platform.h
++++ b/libarchive/archive_platform.h
+@@ -58,6 +58,8 @@
+ * either Windows or Posix APIs. */
+ #if (defined(__WIN32__) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__)
+ #include "archive_windows.h"
++#else
++#define my_stat(fd, st) stat(fd, st)
+ #endif
+
+ /*
+diff --git a/libarchive/archive_read_disk_entry_from_file.c b/libarchive/archive_read_disk_entry_from_file.c
+index e984aaa..ba78321 100644
+--- a/libarchive/archive_read_disk_entry_from_file.c
++++ b/libarchive/archive_read_disk_entry_from_file.c
+@@ -163,7 +163,7 @@ archive_read_disk_entry_from_file(struct archive *_a,
+ }
+ } else
+ #endif
+- if (stat(path, &s) != 0) {
++ if (my_stat(path, &s) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Can't stat %s", path);
+ return (ARCHIVE_FAILED);
+diff --git a/libarchive/archive_util.c b/libarchive/archive_util.c
+index 34d8081..43acd51 100644
+--- a/libarchive/archive_util.c
++++ b/libarchive/archive_util.c
+@@ -433,7 +433,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 (my_stat(temp_name.s, &st) < 0)
+ goto exit_tmpfile;
+ if (!S_ISDIR(st.st_mode)) {
+ errno = ENOTDIR;
+diff --git a/libarchive/archive_windows.h b/libarchive/archive_windows.h
+index c6f5bc5..a178f49 100644
+--- a/libarchive/archive_windows.h
++++ b/libarchive/archive_windows.h
+@@ -112,10 +112,12 @@
+ #if !defined(__BORLANDC__)
+ #define setmode _setmode
+ #endif
+-#ifdef stat
+-#undef stat
+-#endif
+-#define stat(path,stref) __la_stat(path,stref)
++int __la_stat(const char *pathname, struct stat *buf);
++static inline int
++my_stat(const char *pathname, struct stat *st)
++{
++ return __la_stat(pathname, st);
++}
+ #if !defined(__BORLANDC__)
+ #define strdup _strdup
+ #endif
+--
+1.8.4
+
diff --git a/l/libarchive/libarchive.SlackBuild b/l/libarchive/libarchive.SlackBuild
index 3b8a1b0..ac8924d 100755
--- a/l/libarchive/libarchive.SlackBuild
+++ b/l/libarchive/libarchive.SlackBuild
@@ -57,9 +57,12 @@ find . \
-exec chmod 644 {} \;
#! PATCH
-STAT_IS_64="-D__MINGW_USE_VC2005_COMPAT=1 -D_FILE_OFFSET_BITS=64"
+patch -p1 --verbose < ${CWD}/0001-windows-don-t-undef-stat-since-it-my-be-defined-to-s.patch || exit 1
+patch -p0 --verbose < ${CWD}/use-static-asserts-to-guarantee-abi-compatibility.patch || exit 1
#! PATCH
+STAT_IS_64="-D__MINGW_USE_VC2005_COMPAT"
+
CFLAGS="-O2 ${STAT_IS_64}" \
CXXFLAGS="-O2" \
LDFLAGS="-L/${PREFIX}/lib${LIBDIRSUFFIX}" \
diff --git a/l/libarchive/use-static-asserts-to-guarantee-abi-compatibility.patch b/l/libarchive/use-static-asserts-to-guarantee-abi-compatibility.patch
new file mode 100644
index 0000000..bb0597f
--- /dev/null
+++ b/l/libarchive/use-static-asserts-to-guarantee-abi-compatibility.patch
@@ -0,0 +1,26 @@
+--- libarchive/archive.h.old 2014-10-27 08:30:30.031884763 +0100
++++ libarchive/archive.h 2014-10-27 08:30:33.721884875 +0100
+@@ -1037,4 +1037,23 @@
+ /* #undef __LA_INT64_T */
+ /* #undef __LA_SSIZE_T */
+
++/* Take advantage of static_assert/_Static_assert to make sure libarchive is
++ * not built and is not used with a "struct stat" that isn't 64bits.
++ * On Windows I had "stat" #define'd to "stat64" but libarchive #undef'ed it in
++ * its private headers; I then built a program that used libarchive and didn't
++ * have that #undef and got ABI issues: libarchive was storing a 32bit offset
++ * in a "struct stat" but the caller was expecting a 64bit one.
++ * This is a best effort check but which should cover most uses. */
++#ifdef __cplusplus
++#if (__cplusplus >= 201103L)
++static_assert(sizeof(struct stat) == sizeof(struct stat64), "Not using largefile support");
++#endif
++#else
++#if ((defined(__STDC_VERSION) && __STDC_VERSION >= 201112L) \
++ || (defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 6)) \
++ || (defined(__clang__) && (__clang_major__ >= 3) && (__clang_minor__ >= 4)))
++_Static_assert(sizeof(struct stat) == sizeof(struct stat64), "Not using largefile support");
++#endif
++#endif
++
+ #endif /* !ARCHIVE_H_INCLUDED */