summaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http_common.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-11-06 16:17:49 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-11-06 16:17:49 +0000
commitb08368f647fa3d4336006dcfeaa23c29746dd9d3 (patch)
treec762584d4a9c2ed83ab50d291a740a8399ff623d /src/transport/plugin_transport_http_common.c
parentc11962d43dd17ffd037e247752ddaf5f9e837a99 (diff)
test for address to sock
Diffstat (limited to 'src/transport/plugin_transport_http_common.c')
-rw-r--r--src/transport/plugin_transport_http_common.c53
1 files changed, 30 insertions, 23 deletions
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)
{