Skip to content

Commit baa873f

Browse files
committed
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 <[email protected]> Reviewed-by: Eric Blake <[email protected]> Message-id: [email protected]
1 parent a8ca003 commit baa873f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/tcg/multiarch/linux-test.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static void test_time(void)
251251
static int server_socket(void)
252252
{
253253
int val, fd;
254-
struct sockaddr_in sockaddr;
254+
struct sockaddr_in sockaddr = {};
255255

256256
/* server socket */
257257
fd = chk_error(socket(PF_INET, SOCK_STREAM, 0));
@@ -271,7 +271,7 @@ static int server_socket(void)
271271
static int client_socket(uint16_t port)
272272
{
273273
int fd;
274-
struct sockaddr_in sockaddr;
274+
struct sockaddr_in sockaddr = {};
275275

276276
/* server socket */
277277
fd = chk_error(socket(PF_INET, SOCK_STREAM, 0));

0 commit comments

Comments
 (0)