Do value checking in parser
This commit is contained in:
parent
4563b208a6
commit
91b17efc5c
1 changed files with 12 additions and 2 deletions
|
@ -43,8 +43,6 @@ char* parse_ip(char* startptr, struct IP* ip) {
|
|||
char* parse_rule(char line[], struct Rule* result) {
|
||||
enum ParseState state = ParseState_ip1;
|
||||
|
||||
// TODO: check for invalid IP and port ranges where the second IP/port is smaller than the first.
|
||||
|
||||
result->ip.end = NULL;
|
||||
result->port.end = NULL;
|
||||
|
||||
|
@ -121,6 +119,18 @@ char* parse_rule(char line[], struct Rule* result) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result->ip.end != NULL) {
|
||||
if (compare_ip(&result->ip.start, result->ip.end) == 1) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (result->port.end != NULL) {
|
||||
if (akpa_numcmp(result->port.start, *result->port.end) == 1) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
return line + ptr;
|
||||
|
||||
|
|
Reference in a new issue