Fix certain ports being denied sometimes due to memory reuse and faulty bounds checks

This commit is contained in:
akp 2023-11-11 17:09:59 +00:00
parent 181d75abd0
commit f2d1ccd779
2 changed files with 2 additions and 4 deletions

View file

@ -22,7 +22,7 @@ int handle_add_rule(char *data, size_t len) {
if (eptr == NULL) {
retval = HANDLER_INVRULE;
goto end;
} else if ((eptr - data) != len) {
} else if ((eptr - data) < len) {
// This means we've not consumed everything which means that there's extraneous data?
retval = HANDLER_INVRULE;
goto end;
@ -49,8 +49,7 @@ int handle_check_rule(char *data, size_t len) {
endptr = parse_port(endptr, &port);
if (endptr == NULL) {
return HANDLER_ILLEGALARG;
} else if ((endptr - data) != len) {
// TODO: this gets triggered when the port has a trailing zero but is otherwise valid?
} else if ((endptr - data) < len) {
return HANDLER_ILLEGALARG;
}

View file

@ -72,7 +72,6 @@ void add_frame(struct Rule* rule) {
}
int check_ip_and_port(struct IP *ip, Port port) {
// TODO: Something here is broken wrt. ranges of ports and maybe IPs.
// TODO: ip=255.255.255.255??
pthread_rwlock_wrlock(&persist_lock);