On 2026-11-22 10:07, Brian Inglis wrote:
That seems to work, but your patch, originally from coreutils lib/safe-read.c,
applying to diffutils lib/cmpbuf.c block_read, which does not include (nor even
distribute) lib/sys-limits.h defining SYS_BUFSIZE_MAX:
Thanks for reporting that. I didn't see it because I don't use Cygwin. I
installed the attached patch to try to fix it; please give it a try. You'll
need to run './bootstrap' afterwards.
From b904801027cca6cf255871915e961449308f1806 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sun, 22 Nov 2026 22:05:27 -0800
Subject: [PATCH] cmp: port big-buffer fix to Cygwin
Problem reported by Brian Inglis (Bug#82273#32)
* bootstrap.conf (bootstrap_post_import_hook):
Also copy lib/sys-limits.h.
* lib/cmpbuf.c: Include "sys-limits.h", for SYS_BUFSIZE_MAX.
(block_read): Truncate fallback read limit at SYS_BUFSIZE_MAX,
not at INT_MAX / 2 + 1, as this is the tradition elsewhere.
---
bootstrap.conf | 3 ++-
lib/cmpbuf.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 5a5beee..85c4fbb 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -195,7 +195,8 @@ bootstrap_post_import_hook ()
# Automake requires that ChangeLog exist.
touch ChangeLog || exit 1
- # Copy tests/init.sh from Gnulib.
+ # Copy files directly from Gnulib, outside module boundaries.
+ $gnulib_tool --copy-file lib/sys-limits.h
$gnulib_tool --copy-file tests/init.sh
# Copy pkg-config's pkg.m4 so that our downstream users don't need to.
diff --git a/lib/cmpbuf.c b/lib/cmpbuf.c
index f1a0d76..23202db 100644
--- a/lib/cmpbuf.c
+++ b/lib/cmpbuf.c
@@ -31,6 +31,7 @@
#include "intprops.h"
#include "minmax.h"
+#include "sys-limits.h"
/* Read NBYTES bytes from descriptor FD into BUF.
Return the number of characters successfully read.
@@ -62,7 +63,6 @@ block_read (int fd, char *buf, idx_t nbytes)
/* Accommodate macOS, which can't read more than INT_MAX bytes.
FreeBSD behaves similarly if debug.iosize_max_clamp is nonzero.
- Prefer a power of two for the read limit in this case.
Also, work around a bug in Linux kernel 6.3.8 tmpfs,
which fails if the current offset + bytes_to_read exceeds
@@ -80,7 +80,7 @@ block_read (int fd, char *buf, idx_t nbytes)
}
else
{
- readlim = MIN (bytes_to_read >> 1, INT_MAX / 2 + 1);
+ readlim = MIN (bytes_to_read >> 1, SYS_BUFSIZE_MAX);
continue;
}
}
--
2.53.0