Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 01197905 authored by deuce's avatar deuce

When stripping port number, handle IPv6 addresses, and remove [] thing too.

parent 4c2caf47
......@@ -150,15 +150,30 @@ static void remove_port_part(char *host)
{
char *p=strchr(host, 0)-1;
if (!isdigit(*p))
return;
for(; p >= host; p--) {
if (*p == ':') {
*p = 0;
return;
if (isdigit(*p)) {
/*
* If the first and last : are not the same, and it doesn't
* start with '[', there's no port part.
*/
if (host[0] != '[') {
if (strchr(host, ':') != strrchr(host, ':'))
return;
}
for(; p >= host; p--) {
if (*p == ':') {
*p = 0;
break;
}
if (!isdigit(*p))
break;
}
if (!isdigit(*p))
return;
}
// Now, remove []s...
if (host[0] == '[') {
memmove(host, host+1, strlen(host));
p=strchr(host, ']');
if (p)
*p = 0;
}
}
......
......@@ -2820,19 +2820,36 @@ static int is_dynamic_req(http_session_t* session)
static char * split_port_part(char *host)
{
char *ret = NULL;
char *p=strchr(host, 0)-1;
if (!isdigit(*p))
return NULL;
for(; p >= host; p--) {
if (*p == ':') {
*p = 0;
return p+1;
if (isdigit(*p)) {
/*
* If the first and last : are not the same, and it doesn't
* start with '[', there's no port part.
*/
if (host[0] != '[') {
if (strchr(host, ':') != strrchr(host, ':'))
return NULL;
}
for(; p >= host; p--) {
if (*p == ':') {
*p = 0;
ret = p+1;
break;
}
if (!isdigit(*p))
break;
}
if (!isdigit(*p))
return NULL;
}
return NULL;
// Now, remove []s...
if (host[0] == '[') {
memmove(host, host+1, strlen(host));
p=strchr(host, ']');
if (p)
*p = 0;
}
return ret;
}
static void remove_port_part(char *host)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment