From 1f4b9250cf2c609b4f3e4963ac7998cb188b8afd Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Mon, 9 Jun 2014 18:55:27 +0200 Subject: [PATCH] Check that supplied query type is valid --- src/client.c | 3 ++- src/client.h | 2 +- src/iodine.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client.c b/src/client.c index 66c3ef2..f33a8e9 100644 --- a/src/client.c +++ b/src/client.c @@ -167,7 +167,7 @@ client_set_password(const char *cp) password = cp; } -void +int client_set_qtype(char *qtype) { if (!strcasecmp(qtype, "NULL")) @@ -182,6 +182,7 @@ client_set_qtype(char *qtype) do_qtype = T_SRV; else if (!strcasecmp(qtype, "TXT")) do_qtype = T_TXT; + return (do_qtype == T_UNSET); } char * diff --git a/src/client.h b/src/client.h index 69687d1..983b830 100644 --- a/src/client.h +++ b/src/client.h @@ -27,7 +27,7 @@ const char *client_get_raw_addr(); void client_set_nameserver(struct sockaddr_storage *, int); void client_set_topdomain(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(); void client_set_downenc(char *encoding); void client_set_selecttimeout(int select_timeout); diff --git a/src/iodine.c b/src/iodine.c index 2f24889..6cf7cc3 100644 --- a/src/iodine.c +++ b/src/iodine.c @@ -249,7 +249,8 @@ main(int argc, char **argv) pidfile = optarg; break; case 'T': - client_set_qtype(optarg); + if (client_set_qtype(optarg)) + errx(5, "Invalid query type '%s'", optarg); break; case 'O': /* not -D, is Debug in server */ client_set_downenc(optarg);