aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2011-01-10 21:41:30 +0000
committerPhilipp Tölke <toelke@in.tum.de>2011-01-10 21:41:30 +0000
commitbdb2a491e0b595a782cea7177878dbc6a4d49c8f (patch)
tree9080f0695e17de8a6f650a3df469937fb9d54d7c /src/vpn
parent22913a818047f1188a7ee4dadb406b9dc41efe84 (diff)
downloadgnunet-bdb2a491e0b595a782cea7177878dbc6a4d49c8f.tar.gz
gnunet-bdb2a491e0b595a782cea7177878dbc6a4d49c8f.zip
A few static-analysis-changes
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/gnunet-daemon-vpn.c11
-rw-r--r--src/vpn/gnunet-helper-vpn.c35
-rw-r--r--src/vpn/gnunet-service-dns.c1
3 files changed, 39 insertions, 8 deletions
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c
index acdb05ce1..31513f2c2 100644
--- a/src/vpn/gnunet-daemon-vpn.c
+++ b/src/vpn/gnunet-daemon-vpn.c
@@ -209,7 +209,8 @@ cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) {
209 /* stop the helper */ 209 /* stop the helper */
210 if (helper_proc != NULL) 210 if (helper_proc != NULL)
211 { 211 {
212 GNUNET_OS_process_kill (helper_proc, SIGTERM); 212 if (0 != GNUNET_OS_process_kill (helper_proc, SIGTERM))
213 GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING, "kill");
213 GNUNET_OS_process_wait (helper_proc); 214 GNUNET_OS_process_wait (helper_proc);
214 GNUNET_OS_process_close (helper_proc); 215 GNUNET_OS_process_close (helper_proc);
215 helper_proc = NULL; 216 helper_proc = NULL;
@@ -354,6 +355,7 @@ helper_write(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tsdkctx) {
354 size_t pkt_len = sizeof(struct GNUNET_MessageHeader) + sizeof(struct pkt_tun) + net_len; 355 size_t pkt_len = sizeof(struct GNUNET_MessageHeader) + sizeof(struct pkt_tun) + net_len;
355 356
356 struct ip_udp_dns* pkt = alloca(pkt_len); 357 struct ip_udp_dns* pkt = alloca(pkt_len);
358 GNUNET_assert(pkt != NULL);
357 memset(pkt, 0, pkt_len); 359 memset(pkt, 0, pkt_len);
358 360
359 /* set the gnunet-header */ 361 /* set the gnunet-header */
@@ -427,6 +429,7 @@ send_icmp_response(void* cls, const struct GNUNET_SCHEDULER_TaskContext *tc) {
427 struct ip6_icmp* request = cls; 429 struct ip6_icmp* request = cls;
428 430
429 struct ip6_icmp* response = alloca(ntohs(request->shdr.size)); 431 struct ip6_icmp* response = alloca(ntohs(request->shdr.size));
432 GNUNET_assert(response != NULL);
430 memset(response, 0, ntohs(request->shdr.size)); 433 memset(response, 0, ntohs(request->shdr.size));
431 434
432 response->shdr.size = request->shdr.size; 435 response->shdr.size = request->shdr.size;
@@ -538,6 +541,7 @@ message_token(void *cls,
538 if ((key = address_mapping_exists(pkt6->ip6_hdr.dadr)) != NULL) 541 if ((key = address_mapping_exists(pkt6->ip6_hdr.dadr)) != NULL)
539 { 542 {
540 struct map_entry* me = GNUNET_CONTAINER_multihashmap_get(hashmap, key); 543 struct map_entry* me = GNUNET_CONTAINER_multihashmap_get(hashmap, key);
544 GNUNET_assert(me != NULL);
541 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Mapping exists; type: %d; UDP is %d; port: %x/%x!\n", me->desc.service_type, htonl(GNUNET_DNS_SERVICE_TYPE_UDP), pkt6_udp->udp_hdr.dpt, me->desc.ports); 545 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Mapping exists; type: %d; UDP is %d; port: %x/%x!\n", me->desc.service_type, htonl(GNUNET_DNS_SERVICE_TYPE_UDP), pkt6_udp->udp_hdr.dpt, me->desc.ports);
542 GNUNET_free(key); 546 GNUNET_free(key);
543 if (me->desc.service_type & htonl(GNUNET_DNS_SERVICE_TYPE_UDP) && 547 if (me->desc.service_type & htonl(GNUNET_DNS_SERVICE_TYPE_UDP) &&
@@ -619,6 +623,8 @@ connect_to_service_dns (void *cls,
619 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting to service-dns\n"); 623 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting to service-dns\n");
620 GNUNET_assert (dns_connection == NULL); 624 GNUNET_assert (dns_connection == NULL);
621 dns_connection = GNUNET_CLIENT_connect ("dns", cfg); 625 dns_connection = GNUNET_CLIENT_connect ("dns", cfg);
626 /* This would most likely be a misconfiguration */
627 GNUNET_assert(dns_connection != NULL);
622 GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL); 628 GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL, GNUNET_TIME_UNIT_FOREVER_REL);
623 629
624 /* If a packet is already in the list, schedule to send it */ 630 /* If a packet is already in the list, schedule to send it */
@@ -939,6 +945,8 @@ receive_udp_back (void *cls, const struct GNUNET_PeerIdentity *other,
939 945
940 struct ip6_udp* pkt6 = alloca(size); 946 struct ip6_udp* pkt6 = alloca(size);
941 947
948 GNUNET_assert(pkt6 != NULL);
949
942 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Relaying calc:%d gnu:%d udp:%d bytes!\n", size, ntohs(message->size), ntohs(pkt->len)); 950 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Relaying calc:%d gnu:%d udp:%d bytes!\n", size, ntohs(message->size), ntohs(pkt->len));
943 951
944 pkt6->shdr.type = htons(GNUNET_MESSAGE_TYPE_VPN_HELPER); 952 pkt6->shdr.type = htons(GNUNET_MESSAGE_TYPE_VPN_HELPER);
@@ -1038,6 +1046,7 @@ receive_udp_service (void *cls, const struct GNUNET_PeerIdentity *other,
1038 { 1046 {
1039 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating new Socket!\n"); 1047 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating new Socket!\n");
1040 sock = GNUNET_NETWORK_socket_create (AF_INET, SOCK_DGRAM, 0); 1048 sock = GNUNET_NETWORK_socket_create (AF_INET, SOCK_DGRAM, 0);
1049 GNUNET_assert(sock != NULL);
1041 new = GNUNET_YES; 1050 new = GNUNET_YES;
1042 } 1051 }
1043 1052
diff --git a/src/vpn/gnunet-helper-vpn.c b/src/vpn/gnunet-helper-vpn.c
index b8b5b16e6..1d21a431f 100644
--- a/src/vpn/gnunet-helper-vpn.c
+++ b/src/vpn/gnunet-helper-vpn.c
@@ -54,6 +54,12 @@ void term(int sig) {
54static void set_address6(char* dev, char* address, unsigned long prefix_len) { /* {{{ */ 54static void set_address6(char* dev, char* address, unsigned long prefix_len) { /* {{{ */
55 int fd = socket(AF_INET6, SOCK_DGRAM, 0); 55 int fd = socket(AF_INET6, SOCK_DGRAM, 0);
56 56
57 if (fd < 0)
58 {
59 fprintf(stderr, "error creating socket: %m\n");
60 exit(1);
61 }
62
57 struct ifreq ifr; 63 struct ifreq ifr;
58 struct in6_ifreq ifr6; 64 struct in6_ifreq ifr6;
59 65
@@ -62,7 +68,12 @@ static void set_address6(char* dev, char* address, unsigned long prefix_len) { /
62 68
63 sa6.sin6_family = AF_INET6; 69 sa6.sin6_family = AF_INET6;
64 70
65 /* FIXME */ inet_pton(AF_INET6, address, sa6.sin6_addr.s6_addr); 71 int r = inet_pton(AF_INET6, address, sa6.sin6_addr.s6_addr);
72 if (r < 0)
73 {
74 fprintf(stderr, "error at inet_pton: %m\n");
75 exit(1);
76 }
66 77
67 memcpy((char *) &ifr6.ifr6_addr, (char *) &sa6.sin6_addr, sizeof(struct in6_addr)); 78 memcpy((char *) &ifr6.ifr6_addr, (char *) &sa6.sin6_addr, sizeof(struct in6_addr));
68 79
@@ -79,9 +90,9 @@ static void set_address6(char* dev, char* address, unsigned long prefix_len) { /
79 perror("SIOCSIFADDR"); 90 perror("SIOCSIFADDR");
80 } 91 }
81 92
82 /* FIXME */ ioctl(fd, SIOCGIFFLAGS, &ifr); 93 (void)ioctl(fd, SIOCGIFFLAGS, &ifr);
83 ifr.ifr_flags |= IFF_UP | IFF_RUNNING; 94 ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
84 /* FIXME */ ioctl(fd, SIOCSIFFLAGS, &ifr); 95 (void)ioctl(fd, SIOCSIFFLAGS, &ifr);
85 close(fd); 96 close(fd);
86} /* }}} */ 97} /* }}} */
87 98
@@ -96,7 +107,12 @@ static void set_address4(char* dev, char* address, char* mask) { /* {{{ */
96 addr->sin_family = AF_INET; 107 addr->sin_family = AF_INET;
97 addr->sin_addr.s_addr = inet_addr(address); 108 addr->sin_addr.s_addr = inet_addr(address);
98 109
99 /* FIXME */ inet_pton(AF_INET, address, &addr->sin_addr.s_addr); 110 int r = inet_pton(AF_INET, address, &addr->sin_addr.s_addr);
111 if (r < 0)
112 {
113 fprintf(stderr, "error at inet_pton: %m\n");
114 exit(1);
115 }
100 116
101 fd = socket(PF_INET, SOCK_DGRAM, 0); 117 fd = socket(PF_INET, SOCK_DGRAM, 0);
102 if(fd < 0) { 118 if(fd < 0) {
@@ -113,7 +129,12 @@ static void set_address4(char* dev, char* address, char* mask) { /* {{{ */
113 } 129 }
114 130
115 addr = (struct sockaddr_in*)&(ifr.ifr_netmask); 131 addr = (struct sockaddr_in*)&(ifr.ifr_netmask);
116 /* FIXME */ inet_pton(AF_INET, mask, &addr->sin_addr.s_addr); 132 r = inet_pton(AF_INET, mask, &addr->sin_addr.s_addr);
133 if (r < 0)
134 {
135 fprintf(stderr, "error at inet_pton: %m\n");
136 exit(1);
137 }
117 138
118 if(ioctl(fd, SIOCSIFNETMASK, &ifr) != 0 ) { 139 if(ioctl(fd, SIOCSIFNETMASK, &ifr) != 0 ) {
119 perror("SIOCSIFNETMASK"); 140 perror("SIOCSIFNETMASK");
@@ -121,9 +142,9 @@ static void set_address4(char* dev, char* address, char* mask) { /* {{{ */
121 return; 142 return;
122 } 143 }
123 144
124 /* FIXME */ ioctl(fd, SIOCGIFFLAGS, &ifr); 145 (void)ioctl(fd, SIOCGIFFLAGS, &ifr);
125 ifr.ifr_flags |= IFF_UP | IFF_RUNNING; 146 ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
126 /* FIXME */ ioctl(fd, SIOCSIFFLAGS, &ifr); 147 (void)ioctl(fd, SIOCSIFFLAGS, &ifr);
127 close(fd); 148 close(fd);
128} /* }}} */ 149} /* }}} */
129 150
diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c
index 46f324cf7..85ec9ac82 100644
--- a/src/vpn/gnunet-service-dns.c
+++ b/src/vpn/gnunet-service-dns.c
@@ -535,6 +535,7 @@ publish_name (void *cls,
535 535
536 struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file(keyfile); 536 struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file(keyfile);
537 GNUNET_free(keyfile); 537 GNUNET_free(keyfile);
538 GNUNET_assert(my_private_key != NULL);
538 539
539 GNUNET_CRYPTO_rsa_key_get_public(my_private_key, &data.peer); 540 GNUNET_CRYPTO_rsa_key_get_public(my_private_key, &data.peer);
540 541