2025-08-01 Paul Eggert <eggert@cs.ucla.edu>
+ copy-file-range: work around glibc bug 33245
+ Problem reported by Leah Neukirchen <https://bugs.gnu.org/79139>.
+ * lib/copy-file-range.c: Include sys-limits.h.
+ (copy_file_range) [glibc 2.42 and earlier]:
+ Copy at most SYS_BUFSIZE_MAX bytes.
+ * m4/copy-file-range.m4 (gl_FUNC_COPY_FILE_RANGE):
+ Replace on glibc platforms, as well as on Linux platforms.
+ * modules/copy-file-range (Files): Add lib/sys-limits.h.
+
copy-file-range: tune for more-modern kernels
* lib/copy-file-range.c [__linux__ && HAVE_COPY_FILE_RANGE]:
Include <linux/version.h>. Include <sys/utsname.h>
# endif
#endif
+#include "sys-limits.h"
+
ssize_t
copy_file_range (int infd, off_t *pinoff,
int outfd, off_t *poutoff,
# endif
if (ok)
- return copy_file_range (infd, pinoff, outfd, poutoff, length, flags);
+ {
+# if defined __GLIBC__ && ! (2 < __GLIBC__ + (43 <= __GLIBC_MINOR__))
+ /* Work around glibc bug 33245
+ <https://sourceware.org/bugzilla/show_bug.cgi?id=33245>.
+ This bug is present in glibc 2.42 (2025) and fixed in 2.43,
+ so this workaround, and the configure-time check for glibc,
+ can be removed once glibc 2.42 and earlier is no longer a
+ consideration. Perhaps in 2040. */
+ if (SYS_BUFSIZE_MAX < length)
+ length = SYS_BUFSIZE_MAX;
+# endif
+
+ return copy_file_range (infd, pinoff, outfd, poutoff, length, flags);
+ }
#endif
/* There is little need to emulate copy_file_range with read+write,
[Define to 1 if the function copy_file_range exists.])
case $host_os in
- linux*)
- # See copy-file-range.c comment re Linux kernel bugs.
+ *-gnu* | gnu* | linux*)
+ # See copy-file-range.c comment re glibc and Linux kernel bugs.
REPLACE_COPY_FILE_RANGE=1;;
esac
fi