h_addr is a define in in netdb.h
[oweals/gnunet.git] / src / transport / plugin_transport_udp.c
index 46804ba1d525af5b1446c64861ea25827f9cffee..a344ec0cfc6ee050b8d41a5317afbe25e31f69e2 100644 (file)
@@ -559,8 +559,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen)
   uint16_t port;
   uint32_t options;
 
-  options = 0;
-  if (addrlen == sizeof (struct IPv6UdpAddress))
+  if ((NULL != addr) && (addrlen == sizeof (struct IPv6UdpAddress)))
   {
     t6 = addr;
     af = AF_INET6;
@@ -569,7 +568,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen)
     memcpy (&a6, &t6->ipv6_addr, sizeof (a6));
     sb = &a6;
   }
-  else if (addrlen == sizeof (struct IPv4UdpAddress))
+  else if ((NULL != addr) && (addrlen == sizeof (struct IPv4UdpAddress)))
   {
     t4 = addr;
     af = AF_INET;
@@ -622,7 +621,7 @@ udp_string_to_address (void *cls, const char *addr, uint16_t addrlen,
   address = NULL;
   plugin = NULL;
   optionstr = NULL;
-  options = 0;
+
   if ((NULL == addr) || (addrlen == 0))
   {
     GNUNET_break (0);
@@ -795,7 +794,6 @@ udp_plugin_address_pretty_printer (void *cls, const char *type,
   uint16_t port;
   uint32_t options;
 
-  options = 0;
   if (addrlen == sizeof (struct IPv6UdpAddress))
   {
     u6 = addr;
@@ -1256,7 +1254,6 @@ disconnect_session (struct Session *s)
       call_continuation(udpw, GNUNET_SYSERR);
       GNUNET_free (udpw);
     }
-    udpw = next;
   }
   plugin->env->session_end (plugin->env->cls, &s->target, s);
 
@@ -1395,6 +1392,12 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
   struct sockaddr_in6 *v6;
   size_t len;
 
+  if (NULL == addr)
+  {
+       GNUNET_break (0);
+       return NULL;
+  }
+
   switch (addrlen)
   {
   case sizeof (struct IPv4UdpAddress):
@@ -1481,6 +1484,7 @@ session_cmp_it (void *cls,
   {
     struct IPv4UdpAddress * u4 = NULL;
     u4 = (struct IPv4UdpAddress *) address->address;
+    GNUNET_assert (NULL != u4);
     const struct sockaddr_in *s4 = (const struct sockaddr_in *) s->sock_addr;
     if ((0 == memcmp ((const void *) &u4->ipv4_addr,(const void *) &s4->sin_addr, sizeof (struct in_addr))) &&
         (u4->u4_port == s4->sin_port))
@@ -1495,6 +1499,7 @@ session_cmp_it (void *cls,
   {
     struct IPv6UdpAddress * u6 = NULL;
     u6 = (struct IPv6UdpAddress *) address->address;
+    GNUNET_assert (NULL != u6);
     const struct sockaddr_in6 *s6 = (const struct sockaddr_in6 *) s->sock_addr;
     if ((0 == memcmp (&u6->ipv6_addr, &s6->sin6_addr, sizeof (struct in6_addr))) &&
         (u6->u6_port == s6->sin6_port))