mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-08 02:19:18 +02:00
reapplied maxims patches
This commit is contained in:
parent
321781ad85
commit
e7de432088
17
src/common.c
17
src/common.c
|
@ -111,3 +111,20 @@ read_password(char *buf, size_t len)
|
|||
strncpy(buf, pwd, len);
|
||||
buf[len-1] = '\0';
|
||||
}
|
||||
|
||||
int
|
||||
check_topdomain(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(str[0] == '.') /* special case */
|
||||
return 1;
|
||||
|
||||
for( i = 0; i < strlen(str); i++) {
|
||||
if( isalpha(str[i]) || isdigit(str[i]) || str[i] == '-' || str[i] == '.' )
|
||||
continue;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -54,4 +54,6 @@ void do_detach();
|
|||
|
||||
void read_password(char*, size_t);
|
||||
|
||||
int check_topdomain(char *);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -690,8 +690,13 @@ main(int argc, char **argv)
|
|||
|
||||
set_nameserver(nameserv_addr);
|
||||
|
||||
if (strlen(topdomain) > 128 || topdomain[0] == '.') {
|
||||
warnx("Use a topdomain max 128 chars long. Do not start it with a dot.\n");
|
||||
if(strlen(topdomain) <= 128) {
|
||||
if(check_topdomain(topdomain)) {
|
||||
warnx("Topdomain contains invalid characters.\n");
|
||||
usage();
|
||||
}
|
||||
} else {
|
||||
warnx("Use a topdomain max 128 chars long.\n");
|
||||
usage();
|
||||
}
|
||||
|
||||
|
|
|
@ -490,10 +490,6 @@ main(int argc, char **argv)
|
|||
break;
|
||||
case 'p':
|
||||
port = atoi(optarg);
|
||||
if (port) {
|
||||
printf("ALERT! Other dns servers expect you to run on port 53.\n");
|
||||
printf("You must manually forward port 53 to port %d for things to work.\n", port);
|
||||
}
|
||||
break;
|
||||
case 'P':
|
||||
strncpy(password, optarg, sizeof(password));
|
||||
|
@ -520,8 +516,13 @@ main(int argc, char **argv)
|
|||
usage();
|
||||
|
||||
topdomain = strdup(argv[1]);
|
||||
if (strlen(topdomain) > 128 || topdomain[0] == '.') {
|
||||
warnx("Use a topdomain max 128 chars long. Do not start it with a dot.\n");
|
||||
if(strlen(topdomain) <= 128) {
|
||||
if(check_topdomain(topdomain)) {
|
||||
warnx("Topdomain contains invalid characters.\n");
|
||||
usage();
|
||||
}
|
||||
} else {
|
||||
warnx("Use a topdomain max 128 chars long.\n");
|
||||
usage();
|
||||
}
|
||||
|
||||
|
@ -532,10 +533,20 @@ main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
if (mtu == 0) {
|
||||
if (mtu <= 0) {
|
||||
warnx("Bad MTU given.\n");
|
||||
usage();
|
||||
}
|
||||
|
||||
if(port < 1 || port > 65535) {
|
||||
warnx("Bad port number given.\n");
|
||||
usage();
|
||||
}
|
||||
|
||||
if (port != 53) {
|
||||
printf("ALERT! Other dns servers expect you to run on port 53.\n");
|
||||
printf("You must manually forward port 53 to port %d for things to work.\n", port);
|
||||
}
|
||||
|
||||
if (listen_ip == INADDR_NONE) {
|
||||
warnx("Bad IP address to listen on.\n");
|
||||
|
|
Loading…
Reference in New Issue