X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=net.c;h=70d3ec0f2d1ad297a8249acb3bd0f1a1a0815eb9;hb=7d2c2777c3cc16ef50f580f5ff548d8ad6bb0c9b;hp=4a31f013446877e45c780e7eb24a27a0a1042c3a;hpb=1e97f6746b605e37826fb6ee2ad35b7b330145d6;p=paraslash.git diff --git a/net.c b/net.c index 4a31f013..70d3ec0f 100644 --- a/net.c +++ b/net.c @@ -142,9 +142,9 @@ static bool host_string_ok(const char *host) * \param hostlen The maximum length of \a host. * \param port To return the port number (if any) of \a url. * - * \return Pointer to \a host, or NULL if failed. - * If NULL is returned, \a host and \a portnum are undefined. If no - * port number was present in \a url, \a portnum is set to -1. + * \return Pointer to \a host, or \p NULL if failed. If \p NULL is returned, + * \a host and \a port are undefined. If no port number was present in \a url, + * \a port is set to -1. * * \sa RFC 3986, 3.2.2/3.2.3 */ @@ -168,16 +168,16 @@ char *parse_url(const char *url, if (*o++ != ']' || (*o != '\0' && *o != ':')) goto failed; } else { - for (; (*c = *o == ':'? '\0' : *o); c++, o++) - if (c == end) + for (; (*c = *o == ':'? '\0' : *o); c++, o++) { + if (c == end && o[1]) goto failed; + } } if (*o == ':') if (para_atoi32(++o, port) < 0 || *port < 0 || *port > 0xffff) goto failed; - if (host_string_ok(host)) return host; failed: @@ -377,7 +377,6 @@ int makesock(unsigned l4type, bool passive, { struct addrinfo *local = NULL, *src = NULL, *remote = NULL, *dst = NULL, hints; - unsigned int l3type = AF_UNSPEC; int rc, on = 1, sockfd = -1, socktype = sock_type(l4type); char port[6]; /* port number has at most 5 digits */ @@ -385,7 +384,7 @@ int makesock(unsigned l4type, bool passive, sprintf(port, "%u", port_number); /* Set up address hint structure */ memset(&hints, 0, sizeof(hints)); - hints.ai_family = l3type; + hints.ai_family = AF_UNSPEC; hints.ai_socktype = socktype; /* * getaddrinfo does not support SOCK_DCCP, so for the sake of lookup @@ -396,9 +395,6 @@ int makesock(unsigned l4type, bool passive, /* only use addresses available on the host */ hints.ai_flags = AI_ADDRCONFIG; - if (l3type == AF_INET6) - /* use v4-mapped-v6 if no v6 addresses found */ - hints.ai_flags |= AI_V4MAPPED | AI_ALL; if (passive && host == NULL) hints.ai_flags |= AI_PASSIVE;