diff options
author | Andrius Bentkus <andrius.bentkus@gmail.com> | 2014-07-02 15:24:17 +0200 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2014-07-02 20:59:27 -0700 |
commit | a382c9a97c7440f79f0be2f6e2689f4338d35396 (patch) | |
tree | 165a2ef8145e61f1df7f720195486509582b1410 /src/udp_wrap.cc | |
parent | 20247064b63b7937d5374368e236bcf4b184888a (diff) | |
download | node-new-a382c9a97c7440f79f0be2f6e2689f4338d35396.tar.gz |
udp: make it possible to receive empty udp packets
A udp packet can have 0 content. In that case nread will be equal to 0,
but addr != NULL.
Add test case for empty data gram packets and fixed test that checked
for OOB when length == 0.
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src/udp_wrap.cc')
-rw-r--r-- | src/udp_wrap.cc | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index b392e35785..f0d4913339 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -268,7 +268,6 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) { node::Utf8Value address(args[5]); const bool have_callback = args[6]->IsTrue(); - assert(offset < Buffer::Length(buffer_obj)); assert(length <= Buffer::Length(buffer_obj) - offset); SendWrap* req_wrap = new SendWrap(env, req_wrap_obj, have_callback); @@ -396,7 +395,7 @@ void UDPWrap::OnRecv(uv_udp_t* handle, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags) { - if (nread == 0) { + if (nread == 0 && addr == NULL) { if (buf->base != NULL) free(buf->base); return; |