Cannot reuse qname (via name) after read_line_cb..

.. returns.
This commit is contained in:
Willem Toorop 2019-01-23 13:55:29 +01:00
parent 2206558376
commit f72fe60035
1 changed files with 6 additions and 4 deletions

View File

@ -62,8 +62,7 @@ static int quiet = 0;
static int batch_mode = 0; static int batch_mode = 0;
static char *query_file = NULL; static char *query_file = NULL;
static int json = 0; static int json = 0;
static char *the_root = "."; static char name[2048] = ".";
static char *name;
static getdns_context *context; static getdns_context *context;
static getdns_dict *extensions; static getdns_dict *extensions;
static getdns_dict *query_extensions_spc = NULL; static getdns_dict *query_extensions_spc = NULL;
@ -659,7 +658,11 @@ getdns_return_t parse_args(int argc, char **argv)
} else if (arg[0] != '-') { } else if (arg[0] != '-') {
got_qname = 1; got_qname = 1;
name = arg; if (strlen(arg) > sizeof(name)) {
fprintf(stderr, "Query name too long\n");
return GETDNS_RETURN_BAD_DOMAIN_NAME;
}
(void) strlcpy(name, arg, sizeof(name));
continue; continue;
} }
for (c = arg+1; *c; c++) { for (c = arg+1; *c; c++) {
@ -1770,7 +1773,6 @@ main(int argc, char **argv)
{ {
getdns_return_t r; getdns_return_t r;
name = the_root;
if ((r = getdns_context_create(&context, 1))) { if ((r = getdns_context_create(&context, 1))) {
fprintf(stderr, "Create context failed: %d\n", (int)r); fprintf(stderr, "Create context failed: %d\n", (int)r);
return r; return r;