Check that supplied query type is valid

This commit is contained in:
Erik Ekman 2014-06-09 18:55:27 +02:00
parent 4d7678dc5b
commit 1f4b9250cf
3 changed files with 5 additions and 3 deletions

View file

@ -167,7 +167,7 @@ client_set_password(const char *cp)
password = cp; password = cp;
} }
void int
client_set_qtype(char *qtype) client_set_qtype(char *qtype)
{ {
if (!strcasecmp(qtype, "NULL")) if (!strcasecmp(qtype, "NULL"))
@ -182,6 +182,7 @@ client_set_qtype(char *qtype)
do_qtype = T_SRV; do_qtype = T_SRV;
else if (!strcasecmp(qtype, "TXT")) else if (!strcasecmp(qtype, "TXT"))
do_qtype = T_TXT; do_qtype = T_TXT;
return (do_qtype == T_UNSET);
} }
char * char *

View file

@ -27,7 +27,7 @@ const char *client_get_raw_addr();
void client_set_nameserver(struct sockaddr_storage *, int); void client_set_nameserver(struct sockaddr_storage *, int);
void client_set_topdomain(const char *cp); void client_set_topdomain(const char *cp);
void client_set_password(const char *cp); void client_set_password(const char *cp);
void client_set_qtype(char *qtype); int client_set_qtype(char *qtype);
char *client_get_qtype(); char *client_get_qtype();
void client_set_downenc(char *encoding); void client_set_downenc(char *encoding);
void client_set_selecttimeout(int select_timeout); void client_set_selecttimeout(int select_timeout);

View file

@ -249,7 +249,8 @@ main(int argc, char **argv)
pidfile = optarg; pidfile = optarg;
break; break;
case 'T': case 'T':
client_set_qtype(optarg); if (client_set_qtype(optarg))
errx(5, "Invalid query type '%s'", optarg);
break; break;
case 'O': /* not -D, is Debug in server */ case 'O': /* not -D, is Debug in server */
client_set_downenc(optarg); client_set_downenc(optarg);