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

net: fix crash if POLLHUP is received #32590

Closed
wants to merge 2 commits into from

Conversation

santigimeno
Copy link
Member

If the onread socket option is used and a POLLHUP event is received,
libuv returns UV_EOF along with a NULL buffer in the read callback,
causing the crash. Deal with this case.
See: https://github.com/nodejs/node/blob/master/deps/uv/src/unix/stream.c#L1317-L1323

Fixes: #31823

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

If the `onread` socket option is used and a `POLLHUP` event is received,
libuv returns `UV_EOF` along with a `NULL` buffer in the read callback,
causing the crash. Deal with this case.

Fixes: nodejs#31823
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Mar 31, 2020
@nodejs-github-bot
Copy link
Collaborator

src/stream_base.cc Outdated Show resolved Hide resolved
@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 5, 2020
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@addaleax
Copy link
Member

addaleax commented Apr 6, 2020

Landed in c7a235f

addaleax pushed a commit that referenced this pull request Apr 6, 2020
If the `onread` socket option is used and a `POLLHUP` event is received,
libuv returns `UV_EOF` along with a `NULL` buffer in the read callback,
causing the crash. Deal with this case.

Fixes: #31823

PR-URL: #32590
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@addaleax addaleax closed this Apr 6, 2020
BethGriggs pushed a commit that referenced this pull request Apr 7, 2020
If the `onread` socket option is used and a `POLLHUP` event is received,
libuv returns `UV_EOF` along with a `NULL` buffer in the read callback,
causing the crash. Deal with this case.

Fixes: #31823

PR-URL: #32590
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos pushed a commit that referenced this pull request Apr 12, 2020
If the `onread` socket option is used and a `POLLHUP` event is received,
libuv returns `UV_EOF` along with a `NULL` buffer in the read callback,
causing the crash. Deal with this case.

Fixes: #31823

PR-URL: #32590
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos pushed a commit that referenced this pull request Apr 22, 2020
If the `onread` socket option is used and a `POLLHUP` event is received,
libuv returns `UV_EOF` along with a `NULL` buffer in the read callback,
causing the crash. Deal with this case.

Fixes: #31823

PR-URL: #32590
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
animetosho added a commit to animetosho/Nyuu that referenced this pull request Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

net.connection.onread handler: may crash on socket end
6 participants