Skip to content

openrc: avoid converting failed PTY reads to size_t - #1059

Open
pva wants to merge 1 commit into
OpenRC:masterfrom
pva:close-pty-slaves
Open

openrc: avoid converting failed PTY reads to size_t#1059
pva wants to merge 1 commit into
OpenRC:masterfrom
pva:close-pty-slaves

Conversation

@pva

@pva pva commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

openrc-run and rc_logger used read()'s return value as a size_t without checking for errors. Since read() returns an ssize_t, a failure return value -1 was converted to SIZE_MAX.

This path was normally hidden because the reader processes retained slave_tty, preventing the master from reporting a hangup. However, read() may still fail for other reasons, so handle its result explicitly.

With this path handled, it is also safe to close the unused slave_tty descriptors.

openrc-run and rc_logger used read()'s return value as a size_t without
checking for errors. Since read() returns an ssize_t, a failure return
value -1 was converted to SIZE_MAX.

This path was normally hidden because the reader processes retained
slave_tty, preventing the master from reporting a hangup. However, read()
may still fail for other reasons, so handle its result explicitly.

With this path handled, it is also safe to close the unused slave_tty
descriptors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant