host: Ignore spaces around - when parsing ranges
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2006-2012 Tobias Brunner
|
||||
* Copyright (C) 2006-2014 Tobias Brunner
|
||||
* Copyright (C) 2006 Daniel Roethlisberger
|
||||
* Copyright (C) 2005-2006 Martin Willi
|
||||
* Copyright (C) 2005 Jan Hutter
|
||||
@@ -530,19 +530,27 @@ host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port)
|
||||
*/
|
||||
bool host_create_from_range(char *string, host_t **from, host_t **to)
|
||||
{
|
||||
char *pos;
|
||||
char *sep, *pos;
|
||||
|
||||
pos = strchr(string, '-');
|
||||
if (!pos)
|
||||
sep = strchr(string, '-');
|
||||
if (!sep)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
*to = host_create_from_string(pos + 1, 0);
|
||||
for (pos = sep+1; *pos && *pos == ' '; pos++)
|
||||
{
|
||||
/* trim spaces before to address*/
|
||||
}
|
||||
*to = host_create_from_string(pos, 0);
|
||||
if (!*to)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
pos = strndup(string, pos - string);
|
||||
for (pos = sep-1; pos > string && *pos == ' '; pos--)
|
||||
{
|
||||
/* trim spaces behind from address */
|
||||
}
|
||||
pos = strndup(string, pos - string + 1);
|
||||
*from = host_create_from_string_and_family(pos, (*to)->get_family(*to), 0);
|
||||
free(pos);
|
||||
if (!*from)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2006-2009 Tobias Brunner
|
||||
* Copyright (C) 2006-2014 Tobias Brunner
|
||||
* Copyright (C) 2006 Daniel Roethlisberger
|
||||
* Copyright (C) 2005-2008 Martin Willi
|
||||
* Copyright (C) 2005 Jan Hutter
|
||||
|
||||
Reference in New Issue
Block a user