/*
- * 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
*/
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)