Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix port_getn calling. #1215

Merged
merged 2 commits into from
Nov 13, 2024
Merged

Conversation

Berrysoft
Copy link
Contributor

The max passed to port_getn should be the capacity of the buffer, not the length.

If max is zero, nget is the events avaliable in the port. Then the calling to set_len will be unsound.

Ref: https://illumos.org/man/3C/port_getn

@sunfishcode sunfishcode merged commit 0565616 into bytecodealliance:main Nov 13, 2024
44 of 45 checks passed
@sunfishcode
Copy link
Member

Thanks!

sunfishcode added a commit that referenced this pull request Nov 13, 2024
The solarish [`port_getn` function] special-cases a `max` argument value
of 0 to be a query of the number of events available. #1215 added a
special-case to protect the code from doing a resize in that case. And
in case users actually do want to do a query, this PR adds a new
`port_getn_query` function that passes a zero.

[`port_getn` function]: https://illumos.org/man/3C/port_getn
@Berrysoft Berrysoft deleted the fix-illumos-getn branch November 13, 2024 23:23
@Berrysoft
Copy link
Contributor Author

By the way, would you publish a new release for this fix?

sunfishcode added a commit that referenced this pull request Nov 18, 2024
* Add a `port_getn_query` function.

The solarish [`port_getn` function] special-cases a `max` argument value
of 0 to be a query of the number of events available. #1215 added a
special-case to protect the code from doing a resize in that case. And
in case users actually do want to do a query, this PR adds a new
`port_getn_query` function that passes a zero.

[`port_getn` function]: https://illumos.org/man/3C/port_getn

* Fix errors.

* Update src/event/port.rs

Co-authored-by: 王宇逸 <[email protected]>

---------

Co-authored-by: 王宇逸 <[email protected]>
sunfishcode pushed a commit that referenced this pull request Nov 18, 2024
* Fix `port_getn` calling.

* Return immediately if the vector's capacity is 0.
sunfishcode added a commit that referenced this pull request Nov 18, 2024
* Add a `port_getn_query` function.

The solarish [`port_getn` function] special-cases a `max` argument value
of 0 to be a query of the number of events available. #1215 added a
special-case to protect the code from doing a resize in that case. And
in case users actually do want to do a query, this PR adds a new
`port_getn_query` function that passes a zero.

[`port_getn` function]: https://illumos.org/man/3C/port_getn

* Fix errors.

* Update src/event/port.rs

Co-authored-by: 王宇逸 <[email protected]>

---------

Co-authored-by: 王宇逸 <[email protected]>
sunfishcode pushed a commit that referenced this pull request Nov 18, 2024
* Fix `port_getn` calling.

* Return immediately if the vector's capacity is 0.
sunfishcode added a commit that referenced this pull request Nov 18, 2024
* Add a `port_getn_query` function.

The solarish [`port_getn` function] special-cases a `max` argument value
of 0 to be a query of the number of events available. #1215 added a
special-case to protect the code from doing a resize in that case. And
in case users actually do want to do a query, this PR adds a new
`port_getn_query` function that passes a zero.

[`port_getn` function]: https://illumos.org/man/3C/port_getn

* Fix errors.

* Update src/event/port.rs

Co-authored-by: 王宇逸 <[email protected]>

---------

Co-authored-by: 王宇逸 <[email protected]>
@sunfishcode
Copy link
Member

This is now fixed in rustix 0.38.41.

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.

2 participants