Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/zfile.c: Use off_t instead of off64_t #1525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

listout
Copy link

@listout listout commented Jul 20, 2023

First discovered in while building on musl 1. This is because musl-1.2.4 (9999 right now) will remove/removes the LFS compatibility hacks, like fopen64:

The gist is that bad configure tests (suffering from -Wimplicit-function-declaration) would build and link successfully because musl provided these symbols as aliases, despite not needing them (musl natively supports both LFS & time64).

To head this off, these aliases are now gone, but remain in libc.so for binary compatibility.

The proper fix is to just use the regular functions and not anything _LARGEFILE64_SOURCE As a temporary workaround you can typedef off_t to off64_t 2 to get it working.

Signed-off-by: Brahmajit Das brahmajit.xyz@gmail.com

First discovered in while building on musl [1]. This is because
musl-1.2.4 (9999 right now) will remove/removes the LFS compatibility
hacks, like fopen64:
  - https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4
  - https://git.musl-libc.org/cgit/musl/commit/?id=25e6fee27f4a293728dd15b659170e7b9c7db9bc

The gist is that bad configure tests (suffering from
-Wimplicit-function-declaration) would build and link
successfully because musl provided these symbols as aliases, despite not
needing them (musl natively supports both LFS & time64).

To head this off, these aliases are now gone, but remain in libc.so for binary compatibility.

The proper fix is to just use the regular functions and not anything _LARGEFILE64_SOURCE
As a temporary workaround you can typedef off_t to off64_t [2] to get it
working.

[1]: https://bugs.gentoo.org/908582
[2]: gentoo/gentoo#31186
Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
algitbot pushed a commit to alpinelinux/aports that referenced this pull request Oct 22, 2023
Apply the patch from [a PR][0] to the_silver_searcher.

[0]:ggreer/the_silver_searcher#1525
@liweitianux
Copy link

This issue also occurs on DragonFly BSD. I found another way to fix it is to change off64_t to z_off64_t as defined in zconf.h, which has already been included by zfile.c.

@listout
Copy link
Author

listout commented Dec 19, 2023

@ggreer any plans on fixing this?

@thesamesam
Copy link

thesamesam commented Jan 22, 2025

Note that you need a followup for this to do the right thing on 32-bit systems.

First, need to add AC_SYS_LARGEFILE to configure.ac. Then, on top of that:

diff --git a/src/decompress.c b/src/decompress.c
index f0bbb33..1680cd5 100644
--- a/src/decompress.c
+++ b/src/decompress.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
 #include <string.h>
 #include <unistd.h>
 
diff --git a/src/ignore.c b/src/ignore.c
index 88036ef..02b06f4 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
 #include <ctype.h>
 #include <dirent.h>
 #include <limits.h>
diff --git a/src/lang.c b/src/lang.c
index 6d62f72..1f2c020 100644
--- a/src/lang.c
+++ b/src/lang.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/src/log.c b/src/log.c
index f6f4e9a..e6c56ea 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
 #include <stdarg.h>
 #include <stdio.h>
 
diff --git a/src/main.c b/src/main.c
index e116f70..3d3b565 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
 #include <ctype.h>
 #include <pcre.h>
 #include <stdarg.h>
@@ -9,8 +11,6 @@
 #include <windows.h>
 #endif
 
-#include "config.h"
-
 #ifdef HAVE_SYS_CPUSET_H
 #include <sys/cpuset.h>
 #endif
diff --git a/src/options.c b/src/options.c
index 2145b33..2bfac85 100644
--- a/src/options.c
+++ b/src/options.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
 #include <errno.h>
 #include <limits.h>
 #include <stdarg.h>
@@ -8,7 +10,6 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include "config.h"
 #include "ignore.h"
 #include "lang.h"
 #include "log.h"
diff --git a/src/print.c b/src/print.c
index 34dbeff..5d825dd 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
 #include <limits.h>
 #include <stdarg.h>
 #include <stdio.h>
diff --git a/src/print_w32.c b/src/print_w32.c
index a1fd387..ca15da4 100644
--- a/src/print_w32.c
+++ b/src/print_w32.c
@@ -1,5 +1,6 @@
 #ifdef _WIN32
 
+#include "config.h"
 #include "print.h"
 #include <io.h>
 #include <stdarg.h>
diff --git a/src/scandir.c b/src/scandir.c
index 50cb595..425855a 100644
--- a/src/scandir.c
+++ b/src/scandir.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
 #include <dirent.h>
 #include <stdlib.h>
 
diff --git a/src/search.c b/src/search.c
index 40b5662..dc81b4c 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1,3 +1,4 @@
+#include "config.h"
 #include "search.h"
 #include "print.h"
 #include "scandir.h"
diff --git a/src/util.c b/src/util.c
index 90ffb6f..32e91f2 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
 #include <ctype.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -5,7 +7,6 @@
 #include <string.h>
 #include <sys/stat.h>
 
-#include "config.h"
 #include "util.h"
 
 #ifdef _WIN32
diff --git a/src/zfile.c b/src/zfile.c
index 299a519..a8c1c73 100644
--- a/src/zfile.c
+++ b/src/zfile.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
 #ifdef __FreeBSD__
 #include <sys/endian.h>
 #endif
@@ -17,8 +19,6 @@ typedef _off64_t off_t;
 #include <stdlib.h>
 #include <string.h>
 
-#include "config.h"
-
 #ifdef HAVE_ERR_H
 #include <err.h>
 #endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants