commit:     e03c865b4837f0f3699499a77b31fbae21b19b77
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  7 19:52:39 2025 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Tue Jan  7 20:06:25 2025 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=e03c865b

libsandbox: use mmap64 when available

We build libsandbox with _FILE_OFFSET_BITS=64, so we need to call
dlsym("mmap64") to get the right function from glibc.

Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 configure.ac        | 1 +
 libsandbox/memory.c | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/configure.ac b/configure.ac
index 2835794..0ada7d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -211,6 +211,7 @@ AC_CHECK_FUNCS_ONCE(m4_flatten([
        mkstemp64
        mkstemps
        mkstemps64
+       mmap64
        open64
        openat
        openat64

diff --git a/libsandbox/memory.c b/libsandbox/memory.c
index a8f4d4b..69aa972 100644
--- a/libsandbox/memory.c
+++ b/libsandbox/memory.c
@@ -25,7 +25,11 @@ static void *(*_sb_mmap)(void *addr, size_t length, int 
prot, int flags, int fd,
 static void *sb_mmap(void *addr, size_t length, int prot, int flags, int fd, 
off_t offset)
 {
        if (!_sb_mmap)
+#ifdef HAVE_MMAP64
+               _sb_mmap = get_dlsym("mmap64", NULL);
+#else
                _sb_mmap = get_dlsym("mmap", NULL);
+#endif
        return _sb_mmap(addr, length, prot, flags, fd, offset);
 }
 #define mmap sb_mmap

Reply via email to