mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-16 07:47:00 +00:00
getdata: fix one ip ranges when they have trailing spaces in definition
Ranges that defined single IP and followed each other, for example range 10.20.30.40 ; range 10.20.30.41 ; range 10.20.30.42 ; were misinterpreted, and every second (the .41 in example) were skipped. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
d2d8abd660
commit
6379ace9c7
1 changed files with 12 additions and 6 deletions
|
|
@ -250,11 +250,10 @@ void parse_config(int is_include, const char *restrict config_file,
|
|||
&& argument != ITS_AN_INCLUCE) {
|
||||
newclause = true;
|
||||
i = 0;
|
||||
} else if (argument == ITS_A_RANGE_FIRST_IP) {
|
||||
one_ip_range = true;
|
||||
} else if (argument == ITS_A_RANGE_FIRST_IP && one_ip_range == true) {
|
||||
argument = ITS_A_RANGE_SECOND_IP;
|
||||
c = ' ';
|
||||
} else if (argument == ITS_A_RANGE_SECOND_IP) {
|
||||
} else if (argument == ITS_A_RANGE_SECOND_IP && 0 < i) {
|
||||
/* Range ends to ; and this hair in code
|
||||
* make two ranges wrote together like...
|
||||
*
|
||||
|
|
@ -262,6 +261,9 @@ void parse_config(int is_include, const char *restrict config_file,
|
|||
*
|
||||
* ...to be interpreted correctly. */
|
||||
c = ' ';
|
||||
} else if (argument == ITS_A_RANGE_SECOND_IP && i == 0) {
|
||||
range_p->last_ip = range_p->first_ip;
|
||||
goto newrange;
|
||||
}
|
||||
continue;
|
||||
case '{':
|
||||
|
|
@ -310,8 +312,7 @@ void parse_config(int is_include, const char *restrict config_file,
|
|||
}
|
||||
/* Strip white spaces before new clause word. */
|
||||
if ((newclause == true || argument != ITS_NOTHING_INTERESTING)
|
||||
&& isspace(c)
|
||||
&& i == 0) {
|
||||
&& isspace(c) && i == 0 && one_ip_range == false) {
|
||||
continue;
|
||||
}
|
||||
/* Save to word which clause this is. */
|
||||
|
|
@ -337,6 +338,9 @@ void parse_config(int is_include, const char *restrict config_file,
|
|||
}
|
||||
i = 0;
|
||||
argument = is_interesting_config_clause(word);
|
||||
if (argument == ITS_A_RANGE_FIRST_IP) {
|
||||
one_ip_range = true;
|
||||
}
|
||||
}
|
||||
/* words after range, shared-network or include */
|
||||
else if (argument != ITS_NOTHING_INTERESTING) {
|
||||
|
|
@ -348,13 +352,14 @@ void parse_config(int is_include, const char *restrict config_file,
|
|||
case ITS_A_RANGE_SECOND_IP:
|
||||
/* printf ("range 2nd ip: %s\n", word); */
|
||||
range_p = ranges + num_ranges;
|
||||
parse_ipaddr(word, &addr);
|
||||
argument = ITS_NOTHING_INTERESTING;
|
||||
parse_ipaddr(word, &addr);
|
||||
if (one_ip_range == true) {
|
||||
one_ip_range = false;
|
||||
copy_ipaddr(&range_p->first_ip, &addr);
|
||||
}
|
||||
copy_ipaddr(&range_p->last_ip, &addr);
|
||||
newrange:
|
||||
range_p->count = 0;
|
||||
range_p->touched = 0;
|
||||
range_p->backups = 0;
|
||||
|
|
@ -379,6 +384,7 @@ void parse_config(int is_include, const char *restrict config_file,
|
|||
break;
|
||||
}
|
||||
copy_ipaddr(&range_p->first_ip, &addr);
|
||||
one_ip_range = false;
|
||||
argument = ITS_A_RANGE_SECOND_IP;
|
||||
break;
|
||||
case ITS_A_SHAREDNET:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue