diff options
Diffstat (limited to 'src/firejail/profile.c')
-rw-r--r-- | src/firejail/profile.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/firejail/profile.c b/src/firejail/profile.c index 1a944beff..c14f2b1f3 100644 --- a/src/firejail/profile.c +++ b/src/firejail/profile.c | |||
@@ -668,20 +668,25 @@ int profile_check_line(char *ptr, int lineno, const char *fname) { | |||
668 | 668 | ||
669 | // dns | 669 | // dns |
670 | if (strncmp(ptr, "dns ", 4) == 0) { | 670 | if (strncmp(ptr, "dns ", 4) == 0) { |
671 | uint32_t dns; | 671 | |
672 | if (atoip(ptr + 4, &dns)) { | 672 | if (check_ip46_address(ptr + 4) == 0) { |
673 | fprintf(stderr, "Error: invalid DNS server IP address\n"); | 673 | fprintf(stderr, "Error: invalid DNS server IPv4 or IPv6 address\n"); |
674 | return 1; | 674 | exit(1); |
675 | } | 675 | } |
676 | char *dns = strdup(ptr + 4); | ||
677 | if (!dns) | ||
678 | errExit("strdup"); | ||
676 | 679 | ||
677 | if (cfg.dns1 == 0) | 680 | if (cfg.dns1 == NULL) |
678 | cfg.dns1 = dns; | 681 | cfg.dns1 = dns; |
679 | else if (cfg.dns2 == 0) | 682 | else if (cfg.dns2 == NULL) |
680 | cfg.dns2 = dns; | 683 | cfg.dns2 = dns; |
681 | else if (cfg.dns3 == 0) | 684 | else if (cfg.dns3 == NULL) |
682 | cfg.dns3 = dns; | 685 | cfg.dns3 = dns; |
686 | else if (cfg.dns4 == NULL) | ||
687 | cfg.dns4 = dns; | ||
683 | else { | 688 | else { |
684 | fprintf(stderr, "Error: up to 3 DNS servers can be specified\n"); | 689 | fprintf(stderr, "Error: up to 4 DNS servers can be specified\n"); |
685 | return 1; | 690 | return 1; |
686 | } | 691 | } |
687 | return 0; | 692 | return 0; |