diff options
author | Darshan Sen <darshan.sen@postman.com> | 2021-10-03 07:55:19 +0300 |
---|---|---|
committer | Node.js GitHub Bot <github-bot@iojs.org> | 2021-10-09 15:21:41 +0300 |
commit | cca9b95523243044f26aab29bb5976f3ece34c43 (patch) | |
tree | 3a4e52f57bae6809539f5d5d333c242b1d039d76 | |
parent | 7723148758146d22d9da82113c345c8e27754f38 (diff) |
dgram: add `nread` assertion to `UDPWrap::OnRecv`
This asserts that the number of bytes received by the socket is less
than or equal to the size allocated for the temporary storage.
Signed-off-by: Darshan Sen <darshan.sen@postman.com>
PR-URL: https://github.com/nodejs/node/pull/40295
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
-rw-r--r-- | src/udp_wrap.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index f068995e9b0..4a0c6aeaa94 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -20,7 +20,6 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. #include "udp_wrap.h" -#include "allocated_buffer-inl.h" #include "env-inl.h" #include "node_buffer.h" #include "node_sockaddr-inl.h" @@ -725,6 +724,7 @@ void UDPWrap::OnRecv(ssize_t nread, } else if (nread == 0) { bs = ArrayBuffer::NewBackingStore(isolate, 0); } else { + CHECK_LE(static_cast<size_t>(nread), bs->ByteLength()); bs = BackingStore::Reallocate(isolate, std::move(bs), nread); } |