Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
aa29f7ca
Unverified
Commit
aa29f7ca
authored
Apr 28, 2020
by
Luca Boccassi
Committed by
GitHub
Apr 28, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3889 from bluca/fuzzers
Problem: testutil build broken with gcc 4.4 on CentOS 6
parents
1443c0e7
a909e729
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
16 deletions
+18
-16
testutil.cpp
tests/testutil.cpp
+18
-16
No files found.
tests/testutil.cpp
View file @
aa29f7ca
...
@@ -374,7 +374,7 @@ fd_t connect_socket (const char *endpoint_, const int af_, const int protocol_)
...
@@ -374,7 +374,7 @@ fd_t connect_socket (const char *endpoint_, const int af_, const int protocol_)
{
{
struct
sockaddr_storage
addr
;
struct
sockaddr_storage
addr
;
// OSX is very opinionated and wants the size to match the AF family type
// OSX is very opinionated and wants the size to match the AF family type
socklen_t
addr_len
=
sizeof
(
addr
)
;
socklen_t
addr_len
;
const
fd_t
s_pre
=
socket
(
af_
,
SOCK_STREAM
,
protocol_
);
const
fd_t
s_pre
=
socket
(
af_
,
SOCK_STREAM
,
protocol_
);
TEST_ASSERT_NOT_EQUAL
(
-
1
,
s_pre
);
TEST_ASSERT_NOT_EQUAL
(
-
1
,
s_pre
);
...
@@ -406,15 +406,16 @@ fd_t connect_socket (const char *endpoint_, const int af_, const int protocol_)
...
@@ -406,15 +406,16 @@ fd_t connect_socket (const char *endpoint_, const int af_, const int protocol_)
memcpy
(
&
addr
,
in
->
ai_addr
,
in
->
ai_addrlen
);
memcpy
(
&
addr
,
in
->
ai_addr
,
in
->
ai_addrlen
);
addr_len
=
(
socklen_t
)
in
->
ai_addrlen
;
addr_len
=
(
socklen_t
)
in
->
ai_addrlen
;
freeaddrinfo
(
in
);
freeaddrinfo
(
in
);
}
}
else
{
#if defined(ZMQ_HAVE_IPC)
#if defined(ZMQ_HAVE_IPC)
else
{
// Cannot cast addr as gcc 4.4 will fail with strict aliasing errors
struct
sockaddr_un
*
un_addr
=
(
struct
sockaddr_un
*
)
&
addr
;
(
*
(
struct
sockaddr_un
*
)
&
addr
).
sun_family
=
AF_UNIX
;
strcpy
((
*
(
struct
sockaddr_un
*
)
&
addr
).
sun_path
,
endpoint_
);
addr_len
=
sizeof
(
struct
sockaddr_un
);
addr_len
=
sizeof
(
struct
sockaddr_un
);
un_addr
->
sun_family
=
AF_UNIX
;
#else
strcpy
(
un_addr
->
sun_path
,
endpoint_
);
return
retired_fd
;
}
#endif
#endif
}
TEST_ASSERT_SUCCESS_RAW_ERRNO
(
TEST_ASSERT_SUCCESS_RAW_ERRNO
(
connect
(
s_pre
,
(
struct
sockaddr
*
)
&
addr
,
addr_len
));
connect
(
s_pre
,
(
struct
sockaddr
*
)
&
addr
,
addr_len
));
...
@@ -430,7 +431,7 @@ fd_t bind_socket_resolve_port (const char *address_,
...
@@ -430,7 +431,7 @@ fd_t bind_socket_resolve_port (const char *address_,
{
{
struct
sockaddr_storage
addr
;
struct
sockaddr_storage
addr
;
// OSX is very opinionated and wants the size to match the AF family type
// OSX is very opinionated and wants the size to match the AF family type
socklen_t
addr_len
=
sizeof
(
addr
)
;
socklen_t
addr_len
;
const
fd_t
s_pre
=
socket
(
af_
,
SOCK_STREAM
,
protocol_
);
const
fd_t
s_pre
=
socket
(
af_
,
SOCK_STREAM
,
protocol_
);
TEST_ASSERT_NOT_EQUAL
(
-
1
,
s_pre
);
TEST_ASSERT_NOT_EQUAL
(
-
1
,
s_pre
);
...
@@ -460,12 +461,11 @@ fd_t bind_socket_resolve_port (const char *address_,
...
@@ -460,12 +461,11 @@ fd_t bind_socket_resolve_port (const char *address_,
memcpy
(
&
addr
,
in
->
ai_addr
,
in
->
ai_addrlen
);
memcpy
(
&
addr
,
in
->
ai_addr
,
in
->
ai_addrlen
);
addr_len
=
(
socklen_t
)
in
->
ai_addrlen
;
addr_len
=
(
socklen_t
)
in
->
ai_addrlen
;
freeaddrinfo
(
in
);
freeaddrinfo
(
in
);
}
}
else
{
#if defined(ZMQ_HAVE_IPC)
#if defined(ZMQ_HAVE_IPC)
else
{
// Cannot cast addr as gcc 4.4 will fail with strict aliasing errors
struct
sockaddr_un
*
un_addr
=
(
struct
sockaddr_un
*
)
&
addr
;
(
*
(
struct
sockaddr_un
*
)
&
addr
).
sun_family
=
AF_UNIX
;
addr_len
=
sizeof
(
struct
sockaddr_un
);
addr_len
=
sizeof
(
struct
sockaddr_un
);
un_addr
->
sun_family
=
AF_UNIX
;
#if defined ZMQ_HAVE_WINDOWS
#if defined ZMQ_HAVE_WINDOWS
char
buffer
[
MAX_PATH
]
=
""
;
char
buffer
[
MAX_PATH
]
=
""
;
...
@@ -484,14 +484,16 @@ fd_t bind_socket_resolve_port (const char *address_,
...
@@ -484,14 +484,16 @@ fd_t bind_socket_resolve_port (const char *address_,
close
(
fd
);
close
(
fd
);
#endif
#endif
#endif
#endif
strcpy
(
un_addr
->
sun_path
,
buffer
);
strcpy
(
(
*
(
struct
sockaddr_un
*
)
&
addr
).
sun_path
,
buffer
);
memcpy
(
my_endpoint_
,
"ipc://"
,
7
);
memcpy
(
my_endpoint_
,
"ipc://"
,
7
);
strcat
(
my_endpoint_
,
buffer
);
strcat
(
my_endpoint_
,
buffer
);
// TODO check return value of unlink
// TODO check return value of unlink
unlink
(
buffer
);
unlink
(
buffer
);
}
#else
return
retired_fd
;
#endif
#endif
}
TEST_ASSERT_SUCCESS_RAW_ERRNO
(
TEST_ASSERT_SUCCESS_RAW_ERRNO
(
bind
(
s_pre
,
(
struct
sockaddr
*
)
&
addr
,
addr_len
));
bind
(
s_pre
,
(
struct
sockaddr
*
)
&
addr
,
addr_len
));
...
@@ -504,8 +506,8 @@ fd_t bind_socket_resolve_port (const char *address_,
...
@@ -504,8 +506,8 @@ fd_t bind_socket_resolve_port (const char *address_,
sprintf
(
my_endpoint_
,
"%s://%s:%u"
,
sprintf
(
my_endpoint_
,
"%s://%s:%u"
,
protocol_
==
IPPROTO_TCP
?
"tcp"
:
"udp"
,
address_
,
protocol_
==
IPPROTO_TCP
?
"tcp"
:
"udp"
,
address_
,
af_
==
AF_INET
af_
==
AF_INET
?
ntohs
((
(
struct
sockaddr_in
*
)
&
addr
)
->
sin_port
)
?
ntohs
((
*
(
struct
sockaddr_in
*
)
&
addr
).
sin_port
)
:
ntohs
((
(
struct
sockaddr_in6
*
)
&
addr
)
->
sin6_port
));
:
ntohs
((
*
(
struct
sockaddr_in6
*
)
&
addr
).
sin6_port
));
}
}
return
s_pre
;
return
s_pre
;
...
...
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