gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r20966 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r20966 - gnunet/src/transport
Date: Thu, 12 Apr 2012 16:29:58 +0200

Author: wachs
Date: 2012-04-12 16:29:58 +0200 (Thu, 12 Apr 2012)
New Revision: 20966

Modified:
   gnunet/src/transport/plugin_transport_http.c
Log:
- fixed string to address parsing


Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c        2012-04-12 13:28:59 UTC 
(rev 20965)
+++ gnunet/src/transport/plugin_transport_http.c        2012-04-12 14:29:58 UTC 
(rev 20966)
@@ -350,45 +350,56 @@
   struct sockaddr_in6 addr_6;
   struct IPv4HttpAddress * http_4addr;
   struct IPv6HttpAddress * http_6addr;
-  GNUNET_break (0);
   if ((addr == NULL) || (addrlen == 0) || (buf == NULL))
     return GNUNET_SYSERR;
 
   /* protocoll + "://" + ":" */
-  if (addrlen <= strlen (protocol) + 4);
+  if (addrlen <= (strlen (protocol) + 4))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     "Invalid address string `%s' to convert to address\n",
+                     addr);
+    GNUNET_break (0);
     return GNUNET_SYSERR;
+  }
 
-  if (NULL == (addr = strstr(addr_str, "://")))
-      return GNUNET_SYSERR;
-
+  if (NULL == (addr_str = strstr(addr, "://")))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               "Invalid address string `%s' to convert to address\n",
+               addr);
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
   addr_str = &addr_str[3];
 
-  if (GNUNET_OK == GNUNET_STRINGS_to_address_ipv4(addr, strlen(addr_str), 
&addr_4))
+  if (addr_str[strlen(addr_str)-1] == '/')
+    addr_str[strlen(addr_str)-1] = '\0';
+
+  if (GNUNET_OK == GNUNET_STRINGS_to_address_ipv4(addr_str, strlen(addr_str), 
&addr_4))
   {
     http_4addr = GNUNET_malloc (sizeof (struct IPv4HttpAddress));
-    http_4addr = GNUNET_malloc (sizeof (struct IPv6HttpAddress));
     http_4addr->u4_port = addr_4.sin_port;
     http_4addr->ipv4_addr = (uint32_t) addr_4.sin_addr.s_addr;
-
     (*buf) = http_4addr;
     (*added) = sizeof (struct IPv4HttpAddress);
-    GNUNET_break (0);
     return GNUNET_OK;
   }
-  else if (GNUNET_OK == GNUNET_STRINGS_to_address_ipv6(addr, strlen(addr_str), 
&addr_6))
+  else if (GNUNET_OK == GNUNET_STRINGS_to_address_ipv6(addr_str, 
strlen(addr_str), &addr_6))
   {
     http_6addr = GNUNET_malloc (sizeof (struct IPv6HttpAddress));
     http_6addr->u6_port = addr_6.sin6_port;
     http_6addr->ipv6_addr = addr_6.sin6_addr;
-
     (*buf) = http_6addr;
     (*added) = sizeof (struct IPv6HttpAddress);
-    GNUNET_break (0);
     return GNUNET_OK;
-
   }
   else
   {
+    GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+                     "Invalid address string `%s' to convert to address\n",
+                     addr);
+    GNUNET_break (0);
     return GNUNET_SYSERR;
   }
 }
@@ -1443,7 +1454,7 @@
     api->cls = NULL;
     api->address_pretty_printer = &http_plugin_address_pretty_printer;
     api->address_to_string = &http_plugin_address_to_string;
-    api->string_to_address = NULL; // FIXME!
+    api->string_to_address = &http_string_to_address;
     return api;
   }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]