[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r14136 - gnunet/src/vpn
From: |
gnunet |
Subject: |
[GNUnet-SVN] r14136 - gnunet/src/vpn |
Date: |
Mon, 10 Jan 2011 22:41:30 +0100 |
Author: toelke
Date: 2011-01-10 22:41:30 +0100 (Mon, 10 Jan 2011)
New Revision: 14136
Modified:
gnunet/src/vpn/gnunet-daemon-vpn.c
gnunet/src/vpn/gnunet-helper-vpn.c
gnunet/src/vpn/gnunet-service-dns.c
Log:
A few static-analysis-changes
Modified: gnunet/src/vpn/gnunet-daemon-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.c 2011-01-10 19:19:49 UTC (rev 14135)
+++ gnunet/src/vpn/gnunet-daemon-vpn.c 2011-01-10 21:41:30 UTC (rev 14136)
@@ -209,7 +209,8 @@
/* stop the helper */
if (helper_proc != NULL)
{
- GNUNET_OS_process_kill (helper_proc, SIGTERM);
+ if (0 != GNUNET_OS_process_kill (helper_proc, SIGTERM))
+ GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING, "kill");
GNUNET_OS_process_wait (helper_proc);
GNUNET_OS_process_close (helper_proc);
helper_proc = NULL;
@@ -354,6 +355,7 @@
size_t pkt_len = sizeof(struct GNUNET_MessageHeader) + sizeof(struct
pkt_tun) + net_len;
struct ip_udp_dns* pkt = alloca(pkt_len);
+ GNUNET_assert(pkt != NULL);
memset(pkt, 0, pkt_len);
/* set the gnunet-header */
@@ -427,6 +429,7 @@
struct ip6_icmp* request = cls;
struct ip6_icmp* response = alloca(ntohs(request->shdr.size));
+ GNUNET_assert(response != NULL);
memset(response, 0, ntohs(request->shdr.size));
response->shdr.size = request->shdr.size;
@@ -538,6 +541,7 @@
if ((key = address_mapping_exists(pkt6->ip6_hdr.dadr)) != NULL)
{
struct map_entry* me =
GNUNET_CONTAINER_multihashmap_get(hashmap, key);
+ GNUNET_assert(me != NULL);
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);
GNUNET_free(key);
if (me->desc.service_type & htonl(GNUNET_DNS_SERVICE_TYPE_UDP)
&&
@@ -619,6 +623,8 @@
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connecting to service-dns\n");
GNUNET_assert (dns_connection == NULL);
dns_connection = GNUNET_CLIENT_connect ("dns", cfg);
+ /* This would most likely be a misconfiguration */
+ GNUNET_assert(dns_connection != NULL);
GNUNET_CLIENT_receive(dns_connection, &dns_answer_handler, NULL,
GNUNET_TIME_UNIT_FOREVER_REL);
/* If a packet is already in the list, schedule to send it */
@@ -939,6 +945,8 @@
struct ip6_udp* pkt6 = alloca(size);
+ GNUNET_assert(pkt6 != NULL);
+
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Relaying calc:%d gnu:%d udp:%d
bytes!\n", size, ntohs(message->size), ntohs(pkt->len));
pkt6->shdr.type = htons(GNUNET_MESSAGE_TYPE_VPN_HELPER);
@@ -1038,6 +1046,7 @@
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating new Socket!\n");
sock = GNUNET_NETWORK_socket_create (AF_INET, SOCK_DGRAM, 0);
+ GNUNET_assert(sock != NULL);
new = GNUNET_YES;
}
Modified: gnunet/src/vpn/gnunet-helper-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-helper-vpn.c 2011-01-10 19:19:49 UTC (rev 14135)
+++ gnunet/src/vpn/gnunet-helper-vpn.c 2011-01-10 21:41:30 UTC (rev 14136)
@@ -54,6 +54,12 @@
static void set_address6(char* dev, char* address, unsigned long prefix_len) {
/* {{{ */
int fd = socket(AF_INET6, SOCK_DGRAM, 0);
+ if (fd < 0)
+ {
+ fprintf(stderr, "error creating socket: %m\n");
+ exit(1);
+ }
+
struct ifreq ifr;
struct in6_ifreq ifr6;
@@ -62,7 +68,12 @@
sa6.sin6_family = AF_INET6;
- /* FIXME */ inet_pton(AF_INET6, address, sa6.sin6_addr.s6_addr);
+ int r = inet_pton(AF_INET6, address, sa6.sin6_addr.s6_addr);
+ if (r < 0)
+ {
+ fprintf(stderr, "error at inet_pton: %m\n");
+ exit(1);
+ }
memcpy((char *) &ifr6.ifr6_addr, (char *) &sa6.sin6_addr, sizeof(struct
in6_addr));
@@ -79,9 +90,9 @@
perror("SIOCSIFADDR");
}
- /* FIXME */ ioctl(fd, SIOCGIFFLAGS, &ifr);
+ (void)ioctl(fd, SIOCGIFFLAGS, &ifr);
ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
- /* FIXME */ ioctl(fd, SIOCSIFFLAGS, &ifr);
+ (void)ioctl(fd, SIOCSIFFLAGS, &ifr);
close(fd);
} /* }}} */
@@ -96,7 +107,12 @@
addr->sin_family = AF_INET;
addr->sin_addr.s_addr = inet_addr(address);
- /* FIXME */ inet_pton(AF_INET, address, &addr->sin_addr.s_addr);
+ int r = inet_pton(AF_INET, address, &addr->sin_addr.s_addr);
+ if (r < 0)
+ {
+ fprintf(stderr, "error at inet_pton: %m\n");
+ exit(1);
+ }
fd = socket(PF_INET, SOCK_DGRAM, 0);
if(fd < 0) {
@@ -113,7 +129,12 @@
}
addr = (struct sockaddr_in*)&(ifr.ifr_netmask);
- /* FIXME */ inet_pton(AF_INET, mask, &addr->sin_addr.s_addr);
+ r = inet_pton(AF_INET, mask, &addr->sin_addr.s_addr);
+ if (r < 0)
+ {
+ fprintf(stderr, "error at inet_pton: %m\n");
+ exit(1);
+ }
if(ioctl(fd, SIOCSIFNETMASK, &ifr) != 0 ) {
perror("SIOCSIFNETMASK");
@@ -121,9 +142,9 @@
return;
}
- /* FIXME */ ioctl(fd, SIOCGIFFLAGS, &ifr);
+ (void)ioctl(fd, SIOCGIFFLAGS, &ifr);
ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
- /* FIXME */ ioctl(fd, SIOCSIFFLAGS, &ifr);
+ (void)ioctl(fd, SIOCSIFFLAGS, &ifr);
close(fd);
} /* }}} */
Modified: gnunet/src/vpn/gnunet-service-dns.c
===================================================================
--- gnunet/src/vpn/gnunet-service-dns.c 2011-01-10 19:19:49 UTC (rev 14135)
+++ gnunet/src/vpn/gnunet-service-dns.c 2011-01-10 21:41:30 UTC (rev 14136)
@@ -535,6 +535,7 @@
struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key =
GNUNET_CRYPTO_rsa_key_create_from_file(keyfile);
GNUNET_free(keyfile);
+ GNUNET_assert(my_private_key != NULL);
GNUNET_CRYPTO_rsa_key_get_public(my_private_key, &data.peer);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r14136 - gnunet/src/vpn,
gnunet <=