diff options
author | David Barksdale <amatus@amatus.name> | 2016-11-06 15:44:21 -0600 |
---|---|---|
committer | David Barksdale <amatus@amatus.name> | 2016-11-06 15:44:21 -0600 |
commit | f01ae895733b2e0c1716c5034c03d59d16918e2d (patch) | |
tree | 3dc118518cf8e3b097d97f1fe804e7dd605ed780 | |
parent | 121ff998718bd2334f96867348426275be1f818a (diff) |
A couple network API fixes
-rw-r--r-- | gnunet-build/packages/gnunet/gnunet/files/network.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gnunet-build/packages/gnunet/gnunet/files/network.js b/gnunet-build/packages/gnunet/gnunet/files/network.js index 84a9d16..011ec8f 100644 --- a/gnunet-build/packages/gnunet/gnunet/files/network.js +++ b/gnunet-build/packages/gnunet/gnunet/files/network.js @@ -104,8 +104,7 @@ mergeInto(LibraryManager.library, { GNUNET_NETWORK_socket_close: function(desc) { console.debug("socket_close(", desc, ")"); if (!(desc in SOCKETS)) { - ___setErrNo(ERRNO_CODES.EBADF); - return -1; + return 1; } var socket = SOCKETS[desc]; if ("port" in socket) { @@ -155,6 +154,11 @@ mergeInto(LibraryManager.library, { ___setErrNo(ERRNO_CODES.EWOULDBLOCK); return 0; } + var len = {{{ makeGetValue('address_len', '0', 'i32') }}}; + if (len < 110) { + ___setErrNo(ERRNO_CODES.EINVAL); + return 0; + } var data = SOCKETS.incoming.shift(); var sd = NEXT_SOCKET++; var socket = SOCKETS[sd] = { @@ -173,6 +177,7 @@ mergeInto(LibraryManager.library, { } }; {{{ makeSetValue('address', '0', '1', 'i16') }}}; + writeStringToMemory(socket.name.slice(0, 107), address + 2); {{{ makeSetValue('address_len', '0', '110', 'i32') }}}; return sd; }, |