Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
694b6955
Commit
694b6955
authored
Aug 09, 2009
by
Jeff Latimer
Committed by
Alexandre Julliard
Aug 10, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32/tests: Tests for invalid conditions in InetNtop.
parent
eb8f95b5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
3 deletions
+98
-3
socket.c
dlls/ws2_32/socket.c
+22
-3
sock.c
dlls/ws2_32/tests/sock.c
+76
-0
No files found.
dlls/ws2_32/socket.c
View file @
694b6955
...
...
@@ -4709,22 +4709,41 @@ PCSTR WINAPI WS_inet_ntop( INT family, PVOID addr, PSTR buffer, SIZE_T len )
#ifdef HAVE_INET_NTOP
struct
WS_in6_addr
*
in6
;
struct
WS_in_addr
*
in
;
PCSTR
pdst
;
TRACE
(
"family %d, addr (%p), buffer (%p), len %ld
\n
"
,
family
,
addr
,
buffer
,
len
);
if
(
!
buffer
)
{
WSASetLastError
(
STATUS_INVALID_PARAMETER
);
return
NULL
;
}
switch
(
family
)
{
case
WS_AF_INET
:
{
in
=
addr
;
return
inet_ntop
(
AF_INET
,
&
in
->
WS_s_addr
,
buffer
,
len
);
pdst
=
inet_ntop
(
AF_INET
,
&
in
->
WS_s_addr
,
buffer
,
len
);
break
;
}
case
WS_AF_INET6
:
{
in6
=
addr
;
return
inet_ntop
(
AF_INET6
,
in6
->
WS_s6_addr
,
buffer
,
len
);
pdst
=
inet_ntop
(
AF_INET6
,
in6
->
WS_s6_addr
,
buffer
,
len
);
break
;
}
default:
WSASetLastError
(
WSAEAFNOSUPPORT
);
return
NULL
;
}
if
(
!
pdst
)
WSASetLastError
(
STATUS_INVALID_PARAMETER
);
return
pdst
;
#else
FIXME
(
"not supported on this platform
\n
"
);
#endif
WSASetLastError
(
WSAEAFNOSUPPORT
);
return
NULL
;
#endif
}
/***********************************************************************
...
...
dlls/ws2_32/tests/sock.c
View file @
694b6955
...
...
@@ -22,6 +22,8 @@
#include <stdarg.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>
#include <winsock2.h>
...
...
@@ -2234,7 +2236,10 @@ static void test_addr_to_print(void)
PCSTR
addr2_Str
=
"::fffe:cc98:bd74"
;
u_char
addr3_Num
[
16
]
=
{
0x20
,
0x30
,
0xa4
,
0xb1
};
PCSTR
addr3_Str
=
"2030:a4b1::"
;
u_char
addr4_Num
[
16
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0xcC
,
0x98
,
0xbd
,
0x74
};
PCSTR
addr4_Str
=
"::204.152.189.116"
;
/* Test IPv4 addresses */
in
.
s_addr
=
addr0_Num
;
pdst
=
inet_ntoa
(
*
((
struct
in_addr
*
)
&
in
.
s_addr
));
...
...
@@ -2254,6 +2259,7 @@ static void test_addr_to_print(void)
return
;
}
/* Second part of test */
pdst
=
pInetNtop
(
AF_INET
,(
void
*
)
&
in
.
s_addr
,
dst
,
sizeof
(
dst
));
ok
(
pdst
!=
NULL
,
"InetNtop failed %s
\n
"
,
dst
);
ok
(
!
strcmp
(
pdst
,
addr1_Str
),
"Address %s != %s
\n
"
,
pdst
,
addr1_Str
);
...
...
@@ -2263,6 +2269,38 @@ static void test_addr_to_print(void)
ok
(
pdst
==
NULL
,
"The pointer should not be returned (%p)
\n
"
,
pdst
);
ok
(
WSAGetLastError
()
==
WSAEAFNOSUPPORT
,
"Should be WSAEAFNOSUPPORT
\n
"
);
/* Test Null destination */
pdst
=
NULL
;
pdst
=
pInetNtop
(
AF_INET
,
(
void
*
)
&
in
.
s_addr
,
NULL
,
sizeof
(
dst
));
ok
(
pdst
==
NULL
,
"The pointer should not be returned (%p)
\n
"
,
pdst
);
ok
(
WSAGetLastError
()
==
STATUS_INVALID_PARAMETER
,
"Should be STATUS_INVALID_PARAMETER not 0x%x
\n
"
,
WSAGetLastError
());
/* Test zero length passed */
WSASetLastError
(
0
);
pdst
=
NULL
;
pdst
=
pInetNtop
(
AF_INET
,
(
void
*
)
&
in
.
s_addr
,
dst
,
0
);
ok
(
pdst
==
NULL
,
"The pointer should not be returned (%p)
\n
"
,
pdst
);
ok
(
WSAGetLastError
()
==
STATUS_INVALID_PARAMETER
,
"Should be STATUS_INVALID_PARAMETER not 0x%x
\n
"
,
WSAGetLastError
());
/* Test length one shorter than the address length */
WSASetLastError
(
0
);
pdst
=
NULL
;
pdst
=
pInetNtop
(
AF_INET
,
(
void
*
)
&
in
.
s_addr
,
dst
,
6
);
ok
(
pdst
==
NULL
,
"The pointer should not be returned (%p)
\n
"
,
pdst
);
ok
(
WSAGetLastError
()
==
STATUS_INVALID_PARAMETER
,
"Should be STATUS_INVALID_PARAMETER not 0x%x
\n
"
,
WSAGetLastError
());
/* Test longer length is ok */
WSASetLastError
(
0
);
pdst
=
NULL
;
pdst
=
pInetNtop
(
AF_INET
,
(
void
*
)
&
in
.
s_addr
,
dst
,
sizeof
(
dst
)
+
1
);
ok
(
pdst
!=
NULL
,
"The pointer should be returned (%p)
\n
"
,
pdst
);
ok
(
!
strcmp
(
pdst
,
addr1_Str
),
"Address %s != %s
\n
"
,
pdst
,
addr1_Str
);
/* Test the IPv6 addresses */
/* Test an zero prefixed IPV6 address */
memcpy
(
in6
.
u
.
Byte
,
addr2_Num
,
sizeof
(
addr2_Num
));
pdst
=
pInetNtop
(
AF_INET6
,(
void
*
)
&
in6
.
s6_addr
,
dst6
,
sizeof
(
dst6
));
...
...
@@ -2274,6 +2312,44 @@ static void test_addr_to_print(void)
pdst
=
pInetNtop
(
AF_INET6
,(
void
*
)
&
in6
.
s6_addr
,
dst6
,
sizeof
(
dst6
));
ok
(
pdst
!=
NULL
,
"InetNtop failed %s
\n
"
,
dst6
);
ok
(
!
strcmp
(
pdst
,
addr3_Str
),
"Address %s != %s
\n
"
,
pdst
,
addr3_Str
);
/* Test the IPv6 address contains the IPv4 address in IPv4 notation */
memcpy
(
in6
.
s6_addr
,
addr4_Num
,
sizeof
(
addr4_Num
));
pdst
=
pInetNtop
(
AF_INET6
,
(
void
*
)
&
in6
.
s6_addr
,
dst6
,
sizeof
(
dst6
));
ok
(
pdst
!=
NULL
,
"InetNtop failed %s
\n
"
,
dst6
);
ok
(
!
strcmp
(
pdst
,
addr4_Str
),
"Address %s != %s
\n
"
,
pdst
,
addr4_Str
);
/* Test invalid parm conditions */
memcpy
(
in6
.
u
.
Byte
,
addr2_Num
,
sizeof
(
addr2_Num
));
/* Test Null destination */
pdst
=
NULL
;
pdst
=
pInetNtop
(
AF_INET6
,
(
void
*
)
&
in6
.
s6_addr
,
NULL
,
sizeof
(
dst6
));
ok
(
pdst
==
NULL
,
"The pointer should not be returned (%p)
\n
"
,
pdst
);
ok
(
WSAGetLastError
()
==
STATUS_INVALID_PARAMETER
,
"Should be STATUS_INVALID_PARAMETER not 0x%x
\n
"
,
WSAGetLastError
());
/* Test zero length passed */
WSASetLastError
(
0
);
pdst
=
NULL
;
pdst
=
pInetNtop
(
AF_INET6
,
(
void
*
)
&
in6
.
s6_addr
,
dst6
,
0
);
ok
(
pdst
==
NULL
,
"The pointer should not be returned (%p)
\n
"
,
pdst
);
ok
(
WSAGetLastError
()
==
STATUS_INVALID_PARAMETER
,
"Should be STATUS_INVALID_PARAMETER not 0x%x
\n
"
,
WSAGetLastError
());
/* Test length one shorter than the address length */
WSASetLastError
(
0
);
pdst
=
NULL
;
pdst
=
pInetNtop
(
AF_INET6
,
(
void
*
)
&
in6
.
s6_addr
,
dst6
,
16
);
ok
(
pdst
==
NULL
,
"The pointer should not be returned (%p)
\n
"
,
pdst
);
ok
(
WSAGetLastError
()
==
STATUS_INVALID_PARAMETER
,
"Should be STATUS_INVALID_PARAMETER not 0x%x
\n
"
,
WSAGetLastError
());
/* Test longer length is ok */
WSASetLastError
(
0
);
pdst
=
NULL
;
pdst
=
pInetNtop
(
AF_INET6
,
(
void
*
)
&
in6
.
s6_addr
,
dst
,
18
);
ok
(
pdst
!=
NULL
,
"The pointer should be returned (%p)
\n
"
,
pdst
);
}
static
void
test_ioctlsocket
(
void
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment