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

Boost 1.87.0: Construction of io_context throws std::out_of_range if errno=34 before call #1588

Open
rndx21033 opened this issue Jan 18, 2025 · 0 comments

Comments

@rndx21033
Copy link

Boost 1.87.0: Construction of io_context throws std::out_of_range if errno=34 before call:


#include
#include <boost/asio/io_context.hpp>
#include

int main()
{
errno=34; // this will result in the following call throwing an exception
boost::asio::io_context ctx(std::thread::hardware_concurrency());
}

The offending code is in "asio/impl/config.hpp". Calls to strtoull and strtoll are followed by a check for errno==ERANGE, but there is not check first that ensures that the errno is actually relevant and has been set by that call.

Due to ambiguity of whether a return of LONG_MIN/LLONG_MIN/LONG_MAX/LLONG_MAX is due to that value being parsed or due to under/overflow, it seems like the safest course is to set errno=0 before those calls. I have tested this and confirmed that it does avoid the issue.

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

No branches or pull requests

1 participant