mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Fix potential byte order issue
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27046 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
38b55a9298
commit
bcaf737d23
1 changed files with 5 additions and 3 deletions
|
@ -1391,6 +1391,8 @@ setNonBlocking(SOCKET fd)
|
||||||
port: (int)port
|
port: (int)port
|
||||||
family: (int)family
|
family: (int)family
|
||||||
{
|
{
|
||||||
|
uint16_t p = (uint16_t)port;
|
||||||
|
|
||||||
switch (family)
|
switch (family)
|
||||||
{
|
{
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
@ -1402,7 +1404,7 @@ setNonBlocking(SOCKET fd)
|
||||||
addr_c = [address cStringUsingEncoding: NSUTF8StringEncoding];
|
addr_c = [address cStringUsingEncoding: NSUTF8StringEncoding];
|
||||||
memset(&peer, '\0', sizeof(peer));
|
memset(&peer, '\0', sizeof(peer));
|
||||||
peer.sin_family = AF_INET;
|
peer.sin_family = AF_INET;
|
||||||
peer.sin_port = GSSwapHostI16ToBig(port);
|
peer.sin_port = GSSwapHostI16ToBig(p);
|
||||||
ptonReturn = inet_pton(AF_INET, addr_c, &peer.sin_addr);
|
ptonReturn = inet_pton(AF_INET, addr_c, &peer.sin_addr);
|
||||||
if (ptonReturn == 0) // error
|
if (ptonReturn == 0) // error
|
||||||
{
|
{
|
||||||
|
@ -1425,7 +1427,7 @@ setNonBlocking(SOCKET fd)
|
||||||
addr_c = [address cStringUsingEncoding: NSUTF8StringEncoding];
|
addr_c = [address cStringUsingEncoding: NSUTF8StringEncoding];
|
||||||
memset(&peer, '\0', sizeof(peer));
|
memset(&peer, '\0', sizeof(peer));
|
||||||
peer.sin6_family = AF_INET6;
|
peer.sin6_family = AF_INET6;
|
||||||
peer.sin6_port = GSSwapHostI16ToBig(port);
|
peer.sin6_port = GSSwapHostI16ToBig(p);
|
||||||
ptonReturn = inet_pton(AF_INET6, addr_c, &peer.sin6_addr);
|
ptonReturn = inet_pton(AF_INET6, addr_c, &peer.sin6_addr);
|
||||||
if (ptonReturn == 0) // error
|
if (ptonReturn == 0) // error
|
||||||
{
|
{
|
||||||
|
@ -1443,7 +1445,7 @@ setNonBlocking(SOCKET fd)
|
||||||
case AF_LOCAL:
|
case AF_LOCAL:
|
||||||
{
|
{
|
||||||
struct sockaddr_un peer;
|
struct sockaddr_un peer;
|
||||||
const char *c_addr;
|
const char *c_addr;
|
||||||
|
|
||||||
c_addr = [address fileSystemRepresentation];
|
c_addr = [address fileSystemRepresentation];
|
||||||
memset(&peer, '\0', sizeof(peer));
|
memset(&peer, '\0', sizeof(peer));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue