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

Null pointer access #1388

Open
FatsharkGo opened this issue Jun 16, 2020 · 0 comments
Open

Null pointer access #1388

FatsharkGo opened this issue Jun 16, 2020 · 0 comments

Comments

@FatsharkGo
Copy link

We ported folly to Android and encounted an uncaugth exception while disabling the WIFI, debugger shows that the exception throws in the finall logging block of AsyncSSLSocket::performRead list below:

auto errError = ERR_get_error();
VLOG(6) << "AsyncSSLSocket(fd=" << fd_ << ", "
        << "state=" << state_ << ", "
        << "sslState=" << sslState_ << ", "
        << "events=" << std::hex << eventFlags_ << "): "
        << "bytes: " << bytes << ", "
        << "error: " << error << ", "
        << "errno: " << errno << ", "
        << "func: " << ERR_func_error_string(errError) << ", "
        << "reason: " << ERR_reason_error_string(errError);

The root cause of this exception is that ERR_func_error_string cannot mapping errError to a valid string and returns a nullptr, we add some check of these mappings and passed the test case.

const char* err_func = ERR_func_error_string(errError);
const char* err_reason = ERR_reason_error_string(errError);
VLOG(6) << "AsyncSSLSocket(fd=" << fd_ << ", "
        << "state=" << state_ << ", "
        << "sslState=" << sslState_ << ", "
        << "events=" << std::hex << eventFlags_ << "): "
        << "bytes: " << bytes << ", "
        << "error: " << error << ", "
        << "errno: " << errno << ", "
        << "func: " << (err_func ? err_func : "") << ", "
        << "reason: " << (err_reason ? err_reason : "");

Another two functions involve this defect:

  • bool AsyncSSLSocket::willBlock
  • AsyncSocket::WriteResult AsyncSSLSocket::interpretSSLError
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