mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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>
This commit is contained in:
1 parent
38d81380ac
commit
7e02124a06
1 file changed
+1
-1
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user