Skip to content

Commit

Permalink
dgram: add nread assertion to UDPWrap::OnRecv
Browse files Browse the repository at this point in the history
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 <[email protected]>

PR-URL: #40295
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
  • Loading branch information
RaisinTen authored and nodejs-github-bot committed Oct 9, 2021
1 parent 7723148 commit cca9b95
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/udp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit cca9b95

Please sign in to comment.