]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Add workaround for read(2) EINVAL on macOS and FreeBSD [PR102259]
authorJonathan Wakely <jwakely@redhat.com>
Fri, 6 Dec 2024 17:41:01 +0000 (17:41 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 9 Dec 2024 16:01:21 +0000 (16:01 +0000)
commit4065bf7c2c61dd6eb19fdccbcda99000d8e44b7a
treeb8143339e64caf3eeca498447119c6c025ac53e8
parent80bb28cb233e4679265c7847d57a15bf109a0f0e
libstdc++: Add workaround for read(2) EINVAL on macOS and FreeBSD [PR102259]

On macOS and FreeBSD the read(2) system call can return EINVAL for large
sizes, so limit the maximum that we try to read. The calling code in
basic_filebuf::xsgetn will loop until it gets the size it wants, so we don't
need to loop in basic_file::xsgetn, just limit the maximum size.

libstdc++-v3/ChangeLog:

PR libstdc++/102259
* config/io/basic_file_stdio.cc (basic_file::xsgetn): Limit n to
_GLIBCXX_MAX_READ_SIZE if that macro is defined.
* config/os/bsd/darwin/os_defines.h (_GLIBCXX_MAX_READ_SIZE):
Define to INT_MAX-1.
* config/os/bsd/freebsd/os_defines.h (_GLIBCXX_MAX_READ_SIZE):
Likewise.
libstdc++-v3/config/io/basic_file_stdio.cc
libstdc++-v3/config/os/bsd/darwin/os_defines.h
libstdc++-v3/config/os/bsd/freebsd/os_defines.h