- /* Limit the number of bytes to read, to avoid running into unspecified
- behaviour. But keep the file pointer block aligned when doing so.
- Note that in this case we don't need to call read() multiple times here,
- because the caller is prepared to partial results. */
- if (nbytes_to_read > MAX_BYTES_TO_READ)
- nbytes_to_read = MAX_BYTES_TO_READ & ~8191;
+ /* POSIX limits COUNT to SSIZE_MAX, but we limit it further, requiring
+ that COUNT <= INT_MAX, to avoid triggering a bug in Tru64 5.1.
+ When decreasing COUNT, keep the file pointer block-aligned.
+ Note that in any case, read(write) may succeed, yet read(write)
+ fewer than COUNT bytes, so the caller must be prepared to handle
+ partial results. */
+ if (count > INT_MAX)
+ count = INT_MAX & ~8191;