| 61 | extern struct alias_function* alias_fcts; |
| 62 | |
| 63 | static inline int match_domain(char* alias, int alias_len, char* host, int host_len, int accept_subdomain) { |
| 64 | int index_offset; |
| 65 | |
| 66 | /* Check if the alias is a subdomain alias and if so calculate the index offset to start the comparison |
| 67 | * Given an alias my.domain.com or my.great.domain.com and a subdomain of domain.com the comparison should start at domain.com |
| 68 | * a host of domain.com will also match, if the flag is not set then do a strict comparison |
| 69 | */ |
| 70 | if (accept_subdomain) { |
| 71 | index_offset = host_len - alias_len; |
| 72 | // the host we're checking is a shorter len than the alias so no need to compare |
| 73 | if (index_offset < 0) return 0; |
| 74 | // if the offset is greater than 0 we need to ensure the host we're checking has a preceding '.' to ensure it's a subdomain |
| 75 | else if (index_offset > 0 && !(*((host + index_offset) - 1) == '.')) return 0; |
| 76 | |
| 77 | if (strncasecmp(alias, host + index_offset, alias_len)==0) |
| 78 | return 1; |
| 79 | } else if (host_len == alias_len && strncasecmp(alias, host, host_len)==0) { |
| 80 | return 1; |
| 81 | } |
| 82 | |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | /* returns 1 if name is in the alias list; if port=0, port no is ignored |
| 87 | * if proto=0, proto is ignored*/ |
no outgoing calls
no test coverage detected