Commit b617510a authored by Daniel Salzman's avatar Daniel Salzman

kdig: add empty QNAME suppport via -q without a value

parent e038b1ea
......@@ -123,7 +123,8 @@ Set the nameserver port number or service name to send a query to. The default
port is 53.
.TP
\fB\-q\fP \fIname\fP
Set the query name. An explicit variant of \fIname\fP specification.
Set the query name. An explicit variant of \fIname\fP specification. If no \fIname\fP
is provided, empty question section is set.
.TP
\fB\-t\fP \fItype\fP
An explicit \fIquery_type\fP specification. See possible values above.
......
......@@ -102,7 +102,8 @@ Options
port is 53.
**-q** *name*
Set the query name. An explicit variant of *name* specification.
Set the query name. An explicit variant of *name* specification. If no *name*
is provided, empty question section is set.
**-t** *type*
An explicit *query_type* specification. See possible values above.
......
......@@ -409,20 +409,16 @@ static knot_pkt_t *create_query_packet(const query_t *query)
knot_wire_set_opcode(packet->wire, KNOT_OPCODE_NOTIFY);
}
// Create QNAME from string.
// Set packet question if available.
knot_dname_t *qname = knot_dname_from_str_alloc(query->owner);
if (qname == NULL) {
knot_pkt_free(packet);
return NULL;
}
// Set packet question.
int ret = knot_pkt_put_question(packet, qname, query->class_num,
query->type_num);
if (ret != KNOT_EOK) {
knot_dname_free(qname, NULL);
knot_pkt_free(packet);
return NULL;
if (qname != NULL) {
int ret = knot_pkt_put_question(packet, qname, query->class_num,
query->type_num);
if (ret != KNOT_EOK) {
knot_dname_free(qname, NULL);
knot_pkt_free(packet);
return NULL;
}
}
// For IXFR query or NOTIFY query with SOA serial, add a proper section.
......@@ -449,7 +445,7 @@ static knot_pkt_t *create_query_packet(const query_t *query)
}
// Fill in blank SOA rdata to rrset.
ret = knot_rrset_add_rdata(soa, wire, sizeof(wire), &packet->mm);
int ret = knot_rrset_add_rdata(soa, wire, sizeof(wire), &packet->mm);
if (ret != KNOT_EOK) {
knot_rrset_free(soa, &packet->mm);
knot_pkt_free(packet);
......
......@@ -1543,19 +1543,22 @@ static int parse_name(const char *value, list_t *queries, const query_t *conf)
{
query_t *query = NULL;
char *ascii_name = (char *)value;
char *fqd_name = NULL;
if (conf->idn) {
ascii_name = name_from_idn(value);
if (ascii_name == NULL) {
return KNOT_EINVAL;
if (value != NULL) {
if (conf->idn) {
ascii_name = name_from_idn(value);
if (ascii_name == NULL) {
return KNOT_EINVAL;
}
}
}
// If name is not FQDN, append trailing dot.
char *fqd_name = get_fqd_name(ascii_name);
// If name is not FQDN, append trailing dot.
fqd_name = get_fqd_name(ascii_name);
if (conf->idn) {
free(ascii_name);
if (conf->idn) {
free(ascii_name);
}
}
// Create new query.
......@@ -1997,11 +2000,7 @@ static int parse_opt1(const char *opt, const char *value, kdig_params_t *params,
*index += add;
break;
case 'q':
if (val == NULL) {
ERR("missing name\n");
return KNOT_EINVAL;
}
// Allow empty QNAME.
if (parse_name(val, &params->queries, params->config)
!= KNOT_EOK) {
ERR("bad query name %s\n", val);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment