|
61 | 61 | #include "dco.h"
|
62 | 62 | #include "options_util.h"
|
63 | 63 | #include "tun_afunix.h"
|
| 64 | +#include "domain_helper.h" |
64 | 65 |
|
65 | 66 | #include <ctype.h>
|
66 | 67 |
|
@@ -5877,8 +5878,12 @@ check_dns_option(struct options *options, char *p[], const msglvl_t msglevel, bo
|
5877 | 5878 | {
|
5878 | 5879 | if (streq(p[1], "search-domains") && p[2])
|
5879 | 5880 | {
|
5880 |
| - dns_domain_list_append(&options->dns_options.search_domains, &p[2], |
5881 |
| - &options->dns_options.gc); |
| 5881 | + if (!dns_domain_list_append(&options->dns_options.search_domains, &p[2], |
| 5882 | + &options->dns_options.gc)) |
| 5883 | + { |
| 5884 | + msg(msglevel, "--dns %s contain invalid characters", p[1]); |
| 5885 | + return false; |
| 5886 | + } |
5882 | 5887 | }
|
5883 | 5888 | else if (streq(p[1], "server") && p[2] && p[3] && p[4])
|
5884 | 5889 | {
|
@@ -5906,7 +5911,11 @@ check_dns_option(struct options *options, char *p[], const msglvl_t msglevel, bo
|
5906 | 5911 | }
|
5907 | 5912 | else if (streq(p[3], "resolve-domains"))
|
5908 | 5913 | {
|
5909 |
| - dns_domain_list_append(&server->domains, &p[4], &options->dns_options.gc); |
| 5914 | + if (!dns_domain_list_append(&server->domains, &p[4], &options->dns_options.gc)) |
| 5915 | + { |
| 5916 | + msg(msglevel, "--dns server %ld: %s contain invalid characters", priority, p[3]); |
| 5917 | + return false; |
| 5918 | + } |
5910 | 5919 | }
|
5911 | 5920 | else if (streq(p[3], "dnssec") && !p[5])
|
5912 | 5921 | {
|
@@ -5950,6 +5959,11 @@ check_dns_option(struct options *options, char *p[], const msglvl_t msglevel, bo
|
5950 | 5959 | }
|
5951 | 5960 | else if (streq(p[3], "sni") && !p[5])
|
5952 | 5961 | {
|
| 5962 | + if (!validate_domain(p[4])) |
| 5963 | + { |
| 5964 | + msg(msglevel, "--dns server %ld: %s contains invalid characters", priority, p[3]); |
| 5965 | + return false; |
| 5966 | + } |
5953 | 5967 | server->sni = p[4];
|
5954 | 5968 | }
|
5955 | 5969 | else
|
@@ -8551,11 +8565,23 @@ add_option(struct options *options, char *p[], bool is_inline, const char *file,
|
8551 | 8565 |
|
8552 | 8566 | if ((streq(p[1], "DOMAIN") || streq(p[1], "ADAPTER_DOMAIN_SUFFIX")) && p[2] && !p[3])
|
8553 | 8567 | {
|
| 8568 | + if (!validate_domain(p[2])) |
| 8569 | + { |
| 8570 | + msg(msglevel, "--dhcp-option %s contains invalid characters", p[1]); |
| 8571 | + goto err; |
| 8572 | + } |
| 8573 | + |
8554 | 8574 | dhcp->domain = p[2];
|
8555 | 8575 | dhcp_optional = true;
|
8556 | 8576 | }
|
8557 | 8577 | else if (streq(p[1], "DOMAIN-SEARCH") && p[2] && !p[3])
|
8558 | 8578 | {
|
| 8579 | + if (!validate_domain(p[2])) |
| 8580 | + { |
| 8581 | + msg(msglevel, "--dhcp-option %s contains invalid characters", p[1]); |
| 8582 | + goto err; |
| 8583 | + } |
| 8584 | + |
8559 | 8585 | if (dhcp->domain_search_list_len < N_SEARCH_LIST_LEN)
|
8560 | 8586 | {
|
8561 | 8587 | dhcp->domain_search_list[dhcp->domain_search_list_len++] = p[2];
|
|
0 commit comments