aboutsummaryrefslogtreecommitdiff
path: root/src/exit
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-11 16:20:44 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-11 16:20:44 +0000
commit84c6a8e60c15c2f97765cd1b1cecb9c9831d5f10 (patch)
tree4c29617e1b8a52170be87c4c6fa7f50cdbba2832 /src/exit
parent996871b39362b2ce34980d99e7fedfb05075f041 (diff)
downloadgnunet-84c6a8e60c15c2f97765cd1b1cecb9c9831d5f10.tar.gz
gnunet-84c6a8e60c15c2f97765cd1b1cecb9c9831d5f10.zip
-fix possible NPE
Diffstat (limited to 'src/exit')
-rw-r--r--src/exit/gnunet-daemon-exit.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 5b1f5b681..01c87007d 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -678,7 +678,7 @@ hash_redirect_info (struct GNUNET_HashCode *hash,
678 */ 678 */
679static struct TunnelState * 679static struct TunnelState *
680get_redirect_state (int af, 680get_redirect_state (int af,
681 int protocol, 681 int protocol,
682 const void *destination_ip, 682 const void *destination_ip,
683 uint16_t destination_port, 683 uint16_t destination_port,
684 const void *local_ip, 684 const void *local_ip,
@@ -1398,7 +1398,7 @@ setup_fresh_address (int af,
1398 local_address->af = af; 1398 local_address->af = af;
1399 local_address->proto = (uint8_t) proto; 1399 local_address->proto = (uint8_t) proto;
1400 /* default "local" port range is often 32768--61000, 1400 /* default "local" port range is often 32768--61000,
1401 so we pick a random value in that range */ 1401 so we pick a random value in that range */
1402 if ( ( (af == AF_INET) && (proto == IPPROTO_ICMP) ) || 1402 if ( ( (af == AF_INET) && (proto == IPPROTO_ICMP) ) ||
1403 ( (af == AF_INET6) && (proto == IPPROTO_ICMPV6) ) ) 1403 ( (af == AF_INET6) && (proto == IPPROTO_ICMPV6) ) )
1404 local_address->port = 0; 1404 local_address->port = 0;
@@ -1429,7 +1429,7 @@ setup_fresh_address (int af,
1429 do 1429 do
1430 { 1430 {
1431 rnd.s_addr = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1431 rnd.s_addr = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
1432 UINT32_MAX); 1432 UINT32_MAX);
1433 local_address->address.ipv4.s_addr = (addr.s_addr | rnd.s_addr) & mask.s_addr; 1433 local_address->address.ipv4.s_addr = (addr.s_addr | rnd.s_addr) & mask.s_addr;
1434 } 1434 }
1435 while ( (local_address->address.ipv4.s_addr == addr.s_addr) || 1435 while ( (local_address->address.ipv4.s_addr == addr.s_addr) ||
@@ -1696,7 +1696,7 @@ prepare_ipv6_packet (const void *payload, size_t payload_length,
1696 1696
1697 GNUNET_TUN_initialize_ipv6_header (pkt6, 1697 GNUNET_TUN_initialize_ipv6_header (pkt6,
1698 protocol, 1698 protocol,
1699 len, 1699 len,
1700 &src_address->address.ipv6, 1700 &src_address->address.ipv6,
1701 &dst_address->address.ipv6); 1701 &dst_address->address.ipv6);
1702 1702
@@ -1796,7 +1796,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1796 case AF_INET: 1796 case AF_INET:
1797 { 1797 {
1798 struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1]; 1798 struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1];
1799 1799
1800 tun->proto = htons (ETH_P_IPV4); 1800 tun->proto = htons (ETH_P_IPV4);
1801 prepare_ipv4_packet (payload, payload_length, 1801 prepare_ipv4_packet (payload, payload_length,
1802 IPPROTO_TCP, 1802 IPPROTO_TCP,
@@ -1809,7 +1809,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1809 case AF_INET6: 1809 case AF_INET6:
1810 { 1810 {
1811 struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1]; 1811 struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
1812 1812
1813 tun->proto = htons (ETH_P_IPV6); 1813 tun->proto = htons (ETH_P_IPV6);
1814 prepare_ipv6_packet (payload, payload_length, 1814 prepare_ipv6_packet (payload, payload_length,
1815 IPPROTO_TCP, 1815 IPPROTO_TCP,
@@ -1818,7 +1818,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1818 destination_address, 1818 destination_address,
1819 ipv6); 1819 ipv6);
1820 } 1820 }
1821 break; 1821 break;
1822 default: 1822 default:
1823 GNUNET_assert (0); 1823 GNUNET_assert (0);
1824 break; 1824 break;
@@ -2067,16 +2067,6 @@ receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2067 const struct GNUNET_EXIT_TcpDataMessage *data; 2067 const struct GNUNET_EXIT_TcpDataMessage *data;
2068 uint16_t pkt_len = ntohs (message->size); 2068 uint16_t pkt_len = ntohs (message->size);
2069 2069
2070 if (GNUNET_YES == state->is_dns)
2071 {
2072 GNUNET_break_op (0);
2073 return GNUNET_SYSERR;
2074 }
2075 if (GNUNET_SYSERR == state->is_dns)
2076 {
2077 /* tunnel is UDP/TCP from now on */
2078 state->is_dns = GNUNET_NO;
2079 }
2080 GNUNET_STATISTICS_update (stats, 2070 GNUNET_STATISTICS_update (stats,
2081 gettext_noop ("# Bytes received from MESH"), 2071 gettext_noop ("# Bytes received from MESH"),
2082 pkt_len, GNUNET_NO); 2072 pkt_len, GNUNET_NO);
@@ -2104,6 +2094,16 @@ receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
2104 GNUNET_break_op (0); 2094 GNUNET_break_op (0);
2105 return GNUNET_SYSERR; 2095 return GNUNET_SYSERR;
2106 } 2096 }
2097 if (GNUNET_YES == state->is_dns)
2098 {
2099 GNUNET_break_op (0);
2100 return GNUNET_SYSERR;
2101 }
2102 if (GNUNET_SYSERR == state->is_dns)
2103 {
2104 /* tunnel is UDP/TCP from now on */
2105 state->is_dns = GNUNET_NO;
2106 }
2107 2107
2108 GNUNET_break_op (ntohl (data->reserved) == 0); 2108 GNUNET_break_op (ntohl (data->reserved) == 0);
2109 { 2109 {
@@ -2185,7 +2185,7 @@ send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
2185 case AF_INET: 2185 case AF_INET:
2186 { 2186 {
2187 struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1]; 2187 struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1];
2188 2188
2189 tun->proto = htons (ETH_P_IPV4); 2189 tun->proto = htons (ETH_P_IPV4);
2190 GNUNET_TUN_initialize_ipv4_header (ipv4, 2190 GNUNET_TUN_initialize_ipv4_header (ipv4,
2191 IPPROTO_ICMP, 2191 IPPROTO_ICMP,
@@ -2198,7 +2198,7 @@ send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
2198 case AF_INET6: 2198 case AF_INET6:
2199 { 2199 {
2200 struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1]; 2200 struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
2201 2201
2202 tun->proto = htons (ETH_P_IPV6); 2202 tun->proto = htons (ETH_P_IPV6);
2203 GNUNET_TUN_initialize_ipv6_header (ipv6, 2203 GNUNET_TUN_initialize_ipv6_header (ipv6,
2204 IPPROTO_ICMPV6, 2204 IPPROTO_ICMPV6,
@@ -2207,7 +2207,7 @@ send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
2207 &destination_address->address.ipv6); 2207 &destination_address->address.ipv6);
2208 icmp = (struct GNUNET_TUN_IcmpHeader*) &ipv6[1]; 2208 icmp = (struct GNUNET_TUN_IcmpHeader*) &ipv6[1];
2209 } 2209 }
2210 break; 2210 break;
2211 default: 2211 default:
2212 GNUNET_assert (0); 2212 GNUNET_assert (0);
2213 break; 2213 break;
@@ -2783,7 +2783,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
2783 case AF_INET: 2783 case AF_INET:
2784 { 2784 {
2785 struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1]; 2785 struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1];
2786 2786
2787 tun->proto = htons (ETH_P_IPV4); 2787 tun->proto = htons (ETH_P_IPV4);
2788 prepare_ipv4_packet (payload, payload_length, 2788 prepare_ipv4_packet (payload, payload_length,
2789 IPPROTO_UDP, 2789 IPPROTO_UDP,
@@ -2796,7 +2796,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
2796 case AF_INET6: 2796 case AF_INET6:
2797 { 2797 {
2798 struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1]; 2798 struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
2799 2799
2800 tun->proto = htons (ETH_P_IPV6); 2800 tun->proto = htons (ETH_P_IPV6);
2801 prepare_ipv6_packet (payload, payload_length, 2801 prepare_ipv6_packet (payload, payload_length,
2802 IPPROTO_UDP, 2802 IPPROTO_UDP,
@@ -2805,7 +2805,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
2805 destination_address, 2805 destination_address,
2806 ipv6); 2806 ipv6);
2807 } 2807 }
2808 break; 2808 break;
2809 default: 2809 default:
2810 GNUNET_assert (0); 2810 GNUNET_assert (0);
2811 break; 2811 break;
@@ -3310,7 +3310,7 @@ add_services (int proto,
3310 freeaddrinfo (res); 3310 freeaddrinfo (res);
3311 GNUNET_free (serv); 3311 GNUNET_free (serv);
3312 continue; 3312 continue;
3313 } 3313 }
3314 serv->address.address.ipv6 = ((struct sockaddr_in6 *) res->ai_addr)->sin6_addr; 3314 serv->address.address.ipv6 = ((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
3315 break; 3315 break;
3316 default: 3316 default:
@@ -3724,7 +3724,7 @@ run (void *cls, char *const *args GNUNET_UNUSED,
3724 (void) GNUNET_asprintf (&prefixed_regex, "%s%s%s", 3724 (void) GNUNET_asprintf (&prefixed_regex, "%s%s%s",
3725 GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, 3725 GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX,
3726 "4", regex); 3726 "4", regex);
3727 regex4 = GNUNET_REGEX_announce (cfg, 3727 regex4 = GNUNET_REGEX_announce (cfg,
3728 prefixed_regex, 3728 prefixed_regex,
3729 REGEX_REFRESH_FREQUENCY, 3729 REGEX_REFRESH_FREQUENCY,
3730 REGEX_MAX_PATH_LEN_IPV4); 3730 REGEX_MAX_PATH_LEN_IPV4);