From b08368f647fa3d4336006dcfeaa23c29746dd9d3 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Wed, 6 Nov 2013 16:17:49 +0000 Subject: test for address to sock --- src/transport/plugin_transport_http_common.c | 53 ++++++++++++++++------------ 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'src/transport/plugin_transport_http_common.c') diff --git a/src/transport/plugin_transport_http_common.c b/src/transport/plugin_transport_http_common.c index 569a47255..de4cb9a26 100644 --- a/src/transport/plugin_transport_http_common.c +++ b/src/transport/plugin_transport_http_common.c @@ -414,33 +414,40 @@ http_common_socket_from_address (const void *addr, size_t addrlen, int *res) struct sockaddr_storage *s; (*res) = GNUNET_SYSERR; char * to_conv; + size_t urlen; ha = (const struct HttpAddress *) addr; if (NULL == addr) - { - GNUNET_break (0); - return NULL; - } + { + GNUNET_break(0); + return NULL ; + } if (0 >= addrlen) - { - GNUNET_break (0); - return NULL; - } - if (addrlen < sizeof (struct HttpAddress)) - { - GNUNET_break (0); - return NULL; - } - if (addrlen < sizeof (struct HttpAddress) + ntohl (ha->urlen)) - { - /* This is a legacy addresses */ - return NULL; - } - if (((char *) addr)[addrlen-1] != '\0') - { - GNUNET_break (0); - return NULL; - } + { + GNUNET_break(0); + return NULL ; + } + if (addrlen < sizeof(struct HttpAddress)) + { + GNUNET_break(0); + return NULL ; + } + urlen = ntohl (ha->urlen); + if (sizeof(struct HttpAddress) + urlen != addrlen) + { + /* This is a legacy addresses */ + return NULL ; + } + if (addrlen < sizeof(struct HttpAddress) + urlen) + { + /* This is a legacy addresses */ + return NULL ; + } + if (((char *) addr)[addrlen - 1] != '\0') + { + GNUNET_break(0); + return NULL ; + } spa = http_split_address ((const char *) &ha[1]); if (NULL == spa) { -- cgit v1.2.3