fix use of partly initialized struct in tcp test

Properly initialize sockaddr 'name' used by tcp test, and remove
a redundant re-declaration of this variable in a nested scope.

Change-Id: Id6e488308a72be96cca6aa661f088d2c3c67a6a3
Related: CID#188848
This commit is contained in:
Stefan Sperling 2018-11-21 13:20:15 +01:00
parent cf9e5f8c33
commit 3cf5229fa0
1 changed files with 2 additions and 1 deletions

View File

@ -69,7 +69,7 @@ int do_tcp_connect( xmlNodePtr p, int *s )
/* bind to a local addr */
if (strlen(local_src) != 0) {
struct sockaddr_in name;
memset(&name, 0, sizeof(name));
name.sin_family = AF_INET;
name.sin_port = htons(local_port);
name.sin_addr.s_addr = inet_addr(local_src);
@ -91,6 +91,7 @@ int do_tcp_connect( xmlNodePtr p, int *s )
};
memcpy(&addr.s_addr, _host.h_addr_list[0], sizeof(struct in_addr));
memset(&name, 0, sizeof(name));
name.sin_family = AF_INET;
name.sin_port = htons( port );
name.sin_addr = addr;