mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-24 00:59:19 +02:00
Added checks on topdomain name based on patch from Maxim Bourmistrov
This commit is contained in:
parent
98061ccc0e
commit
ac46718c16
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;
|
||||
}
|
||||
|
|
|
@ -46,4 +46,6 @@ void do_detach();
|
|||
|
||||
void read_password(char*, size_t);
|
||||
|
||||
int check_topdomain(char *);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -697,8 +697,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();
|
||||
}
|
||||
|
||||
|
|
|
@ -526,8 +526,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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue