Skip to content

Commit 7e02124

Browse files
RaisinTentargos
authored andcommittedOct 13, 2021
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: #40295 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
1 parent 38d8138 commit 7e02124

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎src/udp_wrap.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
#include "udp_wrap.h"
23-
#include "allocated_buffer-inl.h"
2423
#include "env-inl.h"
2524
#include "node_buffer.h"
2625
#include "node_sockaddr-inl.h"
@@ -725,6 +724,7 @@ void UDPWrap::OnRecv(ssize_t nread,
725724
} else if (nread == 0) {
726725
bs = ArrayBuffer::NewBackingStore(isolate, 0);
727726
} else {
727+
CHECK_LE(static_cast<size_t>(nread), bs->ByteLength());
728728
bs = BackingStore::Reallocate(isolate, std::move(bs), nread);
729729
}
730730

0 commit comments

Comments
 (0)
Please sign in to comment.