tests/tcg/multiarch/linux-test: Zero-initialize sockaddr structs

Zero-initialize sockaddr_in and sockaddr_un structs that we're about
to fill in and pass to bind() or connect(), to ensure we don't leave
possible implementation-defined extension fields as uninitialized
garbage.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 20210813150506.7768-5-peter.maydell@linaro.org
This commit is contained in:
Peter Maydell 2021-08-13 16:05:06 +01:00
parent a8ca0033c2
commit baa873f750

View File

@ -251,7 +251,7 @@ static void test_time(void)
static int server_socket(void)
{
int val, fd;
struct sockaddr_in sockaddr;
struct sockaddr_in sockaddr = {};
/* server socket */
fd = chk_error(socket(PF_INET, SOCK_STREAM, 0));
@ -271,7 +271,7 @@ static int server_socket(void)
static int client_socket(uint16_t port)
{
int fd;
struct sockaddr_in sockaddr;
struct sockaddr_in sockaddr = {};
/* server socket */
fd = chk_error(socket(PF_INET, SOCK_STREAM, 0));