aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/transport/plugin_transport_udp.c23
-rw-r--r--src/transport/plugin_transport_unix.c20
2 files changed, 35 insertions, 8 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index b1da80431..9e28f00d4 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -380,11 +380,30 @@ udp_string_to_address (void *cls, const char *addr, uint16_t addrlen,
380 void **buf, size_t *added) 380 void **buf, size_t *added)
381{ 381{
382 struct sockaddr_storage socket_address; 382 struct sockaddr_storage socket_address;
383 int ret = GNUNET_STRINGS_to_address_ip (addr, addrlen, 383
384 if ((NULL == addr) || (addrlen == 0))
385 {
386 GNUNET_break (0);
387 return GNUNET_SYSERR;
388 }
389
390 if ('\0' != addr[addrlen - 1])
391 {
392 return GNUNET_SYSERR;
393 }
394
395 if (strlen (addr) != addrlen - 1)
396 {
397 return GNUNET_SYSERR;
398 }
399
400 int ret = GNUNET_STRINGS_to_address_ip (addr, strlen (addr),
384 &socket_address); 401 &socket_address);
385 402
386 if (ret != GNUNET_OK) 403 if (ret != GNUNET_OK)
404 {
387 return GNUNET_SYSERR; 405 return GNUNET_SYSERR;
406 }
388 407
389 if (socket_address.ss_family == AF_INET) 408 if (socket_address.ss_family == AF_INET)
390 { 409 {
@@ -395,6 +414,7 @@ udp_string_to_address (void *cls, const char *addr, uint16_t addrlen,
395 u4->u4_port = in4->sin_port; 414 u4->u4_port = in4->sin_port;
396 *buf = u4; 415 *buf = u4;
397 *added = sizeof (struct IPv4UdpAddress); 416 *added = sizeof (struct IPv4UdpAddress);
417 return GNUNET_OK;
398 } 418 }
399 else if (socket_address.ss_family == AF_INET6) 419 else if (socket_address.ss_family == AF_INET6)
400 { 420 {
@@ -405,6 +425,7 @@ udp_string_to_address (void *cls, const char *addr, uint16_t addrlen,
405 u6->u6_port = in6->sin6_port; 425 u6->u6_port = in6->sin6_port;
406 *buf = u6; 426 *buf = u6;
407 *added = sizeof (struct IPv6UdpAddress); 427 *added = sizeof (struct IPv6UdpAddress);
428 return GNUNET_OK;
408 } 429 }
409 return GNUNET_SYSERR; 430 return GNUNET_SYSERR;
410} 431}
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index 9c29aeb14..78025ab75 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -1041,7 +1041,7 @@ unix_plugin_address_pretty_printer (void *cls, const char *type,
1041 * 1041 *
1042 * @param cls closure ('struct Plugin*') 1042 * @param cls closure ('struct Plugin*')
1043 * @param addr string address 1043 * @param addr string address
1044 * @param addrlen length of the address 1044 * @param addrlen length of the address (strlen(addr) + '\0')
1045 * @param buf location to store the buffer 1045 * @param buf location to store the buffer
1046 * If the function returns GNUNET_SYSERR, its contents are undefined. 1046 * If the function returns GNUNET_SYSERR, its contents are undefined.
1047 * @param added length of created address 1047 * @param added length of created address
@@ -1057,14 +1057,20 @@ unix_string_to_address (void *cls, const char *addr, uint16_t addrlen,
1057 return GNUNET_SYSERR; 1057 return GNUNET_SYSERR;
1058 } 1058 }
1059 1059
1060 char * tmp = GNUNET_malloc (addrlen + 1); 1060 if ('\0' != addr[addrlen - 1])
1061 memcpy (tmp, addr, addrlen); 1061 {
1062 tmp[addrlen] = '\0'; 1062 GNUNET_break (0);
1063 return GNUNET_SYSERR;
1064 }
1063 1065
1064 //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "`%s'\n", tmp); 1066 if (strlen (addr) != addrlen - 1)
1067 {
1068 GNUNET_break (0);
1069 return GNUNET_SYSERR;
1070 }
1065 1071
1066 (*buf) = tmp; 1072 (*buf) = strdup (addr);
1067 (*added) = strlen (tmp) + 1; 1073 (*added) = strlen (addr) + 1;
1068 return GNUNET_OK; 1074 return GNUNET_OK;
1069} 1075}
1070 1076