Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: native_client_sdk/src/libraries/nacl_io/socket/socket_node.cc

Issue 310903002: nacl_io: only copy up to the size of the sockaddr_in*, not the given len. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/libraries/nacl_io/socket/socket_node.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/socket_node.cc b/native_client_sdk/src/libraries/nacl_io/socket/socket_node.cc
index 831345557bd91d5f3ee3e35d3f3715c6f1a3bfc6..1fa78645ce1d5d70afa6c72ff905a3634deba628 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/socket_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/socket/socket_node.cc
@@ -157,10 +157,11 @@ socklen_t SocketNode::ResourceToSockAddr(PP_Resource addr,
addr4.sin_family = AF_INET;
addr4.sin_port = ipv4.port;
memcpy(&addr4.sin_addr, ipv4.addr, sizeof(ipv4.addr));
+ len = sizeof(addr4);
jvoung (off chromium) 2014/06/03 19:24:23 Hmm, not sure of the point of the len argument the
Sam Clegg 2014/06/03 19:32:43 I think we should mimik the behavior of getsocknam
binji 2014/06/03 20:10:05 +1, the opengroup spec says the same thing. http:/
jvoung (off chromium) 2014/06/03 21:59:32 Done.
memcpy(out_addr, &addr4, len);
- // Returns required size not copied size like getpeername/getsockname.
- return sizeof(sockaddr_in);
+ // Returns required size not like getpeername/getsockname.
+ return len;
}
if (PP_TRUE == NetInterface()->DescribeAsIPv6Address(addr, &ipv6)) {
@@ -168,10 +169,11 @@ socklen_t SocketNode::ResourceToSockAddr(PP_Resource addr,
addr6.sin6_family = AF_INET6;
addr6.sin6_port = ipv6.port;
memcpy(&addr6.sin6_addr, ipv6.addr, sizeof(ipv6.addr));
+ len = sizeof(addr6);
memcpy(out_addr, &addr6, len);
- // Returns required size not copied size like getpeername/getsockname.
- return sizeof(sockaddr_in6);
+ // Returns required size not like getpeername/getsockname.
+ return len;
}
return 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698