Author: tjansen Date: Thu Oct 29 14:32:37 2009 New Revision: 1403 Log: Fixed or removed faulty structure initialization. struct sockaddr_in addr = {0}; only sets the first member of the structure (in this case sin_family) to 0, leaving the other fields uninitialized. Modified: trunk/community-operator/co_client.c trunk/community-operator/co_server.c trunk/libpisa/ctrlhandler.c trunk/libpisa/hitlist.c trunk/libpisa/pisaconf.c trunk/libpisa/tunnel.c trunk/pairing/management.c trunk/pairing/send.c trunk/test/udpclient.c trunk/test/udpserver.c Modified: trunk/community-operator/co_client.c ============================================================================== --- trunk/community-operator/co_client.c Thu Oct 29 14:15:35 2009 (r1402) +++ trunk/community-operator/co_client.c Thu Oct 29 14:32:37 2009 (r1403) @@ -311,10 +311,11 @@ */ static int retrieve_new_cert(void) { - struct sockaddr_in6 srv_addr = { 0 }; + struct sockaddr_in6 srv_addr; char *cert = NULL; int count; + memset(&srv_addr, 0, sizeof(srv_addr)); srv_addr.sin6_family = AF_INET6; inet_pton(PF_INET6, co_client_config.srv_hit, &(srv_addr.sin6_addr)); srv_addr.sin6_port = htons(co_client_config.port); Modified: trunk/community-operator/co_server.c ============================================================================== --- trunk/community-operator/co_server.c Thu Oct 29 14:15:35 2009 (r1402) +++ trunk/community-operator/co_server.c Thu Oct 29 14:32:37 2009 (r1403) @@ -48,7 +48,7 @@ static int create_server_socket(void) { int s, one = 1, port; - struct sockaddr_in6 addr = { 0 }; + struct sockaddr_in6 addr; if ((s = socket(PF_INET6, SOCK_DGRAM, 0)) == 0) { PISA_ERROR("socket() failed.\n"); @@ -60,6 +60,7 @@ pisa_cfg_get_int_value("port", &port); + memset(&addr, 0, sizeof(addr)); addr.sin6_family = AF_INET6; addr.sin6_addr = in6addr_any; addr.sin6_port = htons(port); @@ -234,7 +235,7 @@ size_t addrlen; char *addr_string; co_packet *packet; - struct sockaddr_in6 cl_addr = { 0 }; + struct sockaddr_in6 cl_addr; if (getuid() != 0) { PISA_ERROR("You're not root. HIPD won't sign certificates.\n"); Modified: trunk/libpisa/ctrlhandler.c ============================================================================== --- trunk/libpisa/ctrlhandler.c Thu Oct 29 14:15:35 2009 (r1402) +++ trunk/libpisa/ctrlhandler.c Thu Oct 29 14:32:37 2009 (r1403) @@ -68,7 +68,7 @@ { pisa_packet pkt; int len; - struct sockaddr_in6 addr = {0}; + struct sockaddr_in6 addr; socklen_t addrlen = sizeof(addr); pisa_ctrlhandler *h; pisa_tlv_type type; Modified: trunk/libpisa/hitlist.c ============================================================================== --- trunk/libpisa/hitlist.c Thu Oct 29 14:15:35 2009 (r1402) +++ trunk/libpisa/hitlist.c Thu Oct 29 14:32:37 2009 (r1403) @@ -33,7 +33,7 @@ /* The string didn't contain a valid network address string */ fprintf(stderr, "Invalid network address string:<%s>\n", buffer); } else { - struct tm tm = {0}; + struct tm tm; pisa_cfg_get_group_string_value(g, "expires", buffer, sizeof(buffer)); strptime(buffer, "%Y-%m-%d %H:%M:%S", &tm); hl->entries[hl->cur_slots].expiration = mktime(&tm); Modified: trunk/libpisa/pisaconf.c ============================================================================== --- trunk/libpisa/pisaconf.c Thu Oct 29 14:15:35 2009 (r1402) +++ trunk/libpisa/pisaconf.c Thu Oct 29 14:32:37 2009 (r1403) @@ -65,7 +65,7 @@ pisa_conf_packet pkt; unsigned int addrlen = 0; ssize_t len = 0; - struct sockaddr_in6 from = {0}; + struct sockaddr_in6 from; addrlen = sizeof(from); @@ -92,7 +92,7 @@ int pisa_conf_open_server_socket(int port) { int fd_peer = -1; - struct sockaddr_in6 sin = {0}; + struct sockaddr_in6 sin; int on = 1; fd_peer = socket(AF_INET6, SOCK_DGRAM, 0); @@ -102,6 +102,7 @@ setsockopt(fd_peer, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + memset(&sin, 0, sizeof(sin)); sin.sin6_family = AF_INET6; sin.sin6_addr = in6addr_loopback; sin.sin6_port = htons(port); @@ -122,7 +123,7 @@ { int fd_peer = -1; int res; - struct sockaddr_in6 sin = {0}; + struct sockaddr_in6 sin; int on = 1; fd_peer = socket(AF_INET6, SOCK_DGRAM, 0); @@ -132,6 +133,7 @@ setsockopt(fd_peer, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + memset(&sin, 0, sizeof(sin)); sin.sin6_family = AF_INET6; sin.sin6_addr = in6addr_loopback; sin.sin6_port = htons(port); Modified: trunk/libpisa/tunnel.c ============================================================================== --- trunk/libpisa/tunnel.c Thu Oct 29 14:15:35 2009 (r1402) +++ trunk/libpisa/tunnel.c Thu Oct 29 14:32:37 2009 (r1403) @@ -133,7 +133,7 @@ int pisa_tunnel_open_socket(int port) { int fd_peer=-1; - struct sockaddr_in6 sin = {0}; + struct sockaddr_in6 sin; int on=1; fd_peer = socket(AF_INET6, SOCK_DGRAM, 0); @@ -143,6 +143,7 @@ setsockopt(fd_peer, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + memset(&sin, 0, sizeof(sin)); sin.sin6_family = AF_INET6; sin.sin6_addr = in6addr_any; sin.sin6_port = htons(port); Modified: trunk/pairing/management.c ============================================================================== --- trunk/pairing/management.c Thu Oct 29 14:15:35 2009 (r1402) +++ trunk/pairing/management.c Thu Oct 29 14:32:37 2009 (r1403) @@ -382,14 +382,17 @@ { int result = 0; - struct options options = { 0 }; + struct options options; pisa_hitlist *hitlist_allowed_hosts = NULL; pisa_hitlist_entry *entry = NULL; pisa_userlist *userlist = NULL; pisa_userlist_entry *ulentry = NULL; pisa_userhitlist *merged_list = NULL; pisa_userhitlist_entry *uhlentry = NULL; - pisa_userhitlist_entry new_entry = {}; + pisa_userhitlist_entry new_entry; + + memset(&options, 0, sizeof(options)); + memset(&new_entry, 0, sizeof(new_entry)); if(!get_lock()) { Modified: trunk/pairing/send.c ============================================================================== --- trunk/pairing/send.c Thu Oct 29 14:15:35 2009 (r1402) +++ trunk/pairing/send.c Thu Oct 29 14:32:37 2009 (r1403) @@ -12,7 +12,7 @@ #include "send.h" -struct global_send_variables global_send = {0}; +struct global_send_variables global_send; /** @todo Make sure that the address we're sending from is a HIT **/ @@ -30,7 +30,7 @@ header_general *gen_hdr; int connected = 0; - + memset(&global_send, 0, sizeof(global_send)); // Parse command line options Modified: trunk/test/udpclient.c ============================================================================== --- trunk/test/udpclient.c Thu Oct 29 14:15:35 2009 (r1402) +++ trunk/test/udpclient.c Thu Oct 29 14:32:37 2009 (r1403) @@ -14,10 +14,11 @@ #include <netinet/in.h> #include <arpa/inet.h> #include <sys/socket.h> +#include <string.h> int main(int argc, char **argv) { - struct sockaddr_in addr = {0}; + struct sockaddr_in addr; char buf[20] = "hello world"; int s; @@ -29,6 +30,7 @@ if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1) return 1; + memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(7777); if (inet_aton(argv[1], &addr.sin_addr)==0) { Modified: trunk/test/udpserver.c ============================================================================== --- trunk/test/udpserver.c Thu Oct 29 14:15:35 2009 (r1402) +++ trunk/test/udpserver.c Thu Oct 29 14:32:37 2009 (r1403) @@ -14,10 +14,11 @@ #include <netinet/in.h> #include <arpa/inet.h> #include <sys/socket.h> +#include <string.h> int main(void) { - struct sockaddr_in addr = {0}; + struct sockaddr_in addr; size_t len = sizeof(addr); char buf[2048]; int s; @@ -25,6 +26,7 @@ if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1) return 1; + memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(7777); addr.sin_addr.s_addr = htonl(INADDR_ANY);