test case ensures tag for caa is not blank

pull/614/head
Brad House 1 year ago
parent 991bcdba6e
commit 9a01e766ed
  1. 20
      src/lib/ares_dns_parse.c

@ -66,7 +66,8 @@ static ares_status_t ares_dns_parse_and_set_dns_str(ares__buf_t *buf,
size_t max_len, size_t max_len,
ares_bool_t allow_multiple, ares_bool_t allow_multiple,
ares_dns_rr_t *rr, ares_dns_rr_t *rr,
ares_dns_rr_key_t key) ares_dns_rr_key_t key,
ares_bool_t blank_allowed)
{ {
ares_status_t status; ares_status_t status;
char *str = NULL; char *str = NULL;
@ -76,6 +77,11 @@ static ares_status_t ares_dns_parse_and_set_dns_str(ares__buf_t *buf,
return status; return status;
} }
if (!blank_allowed && ares_strlen(str) == 0) {
ares_free(str);
return ARES_EBADRESP;
}
status = ares_dns_rr_set_str_own(rr, key, str); status = ares_dns_rr_set_str_own(rr, key, str);
if (status != ARES_SUCCESS) { if (status != ARES_SUCCESS) {
ares_free(str); ares_free(str);
@ -255,7 +261,7 @@ static ares_status_t ares_dns_parse_rr_hinfo(ares__buf_t *buf,
/* CPU */ /* CPU */
status = ares_dns_parse_and_set_dns_str( status = ares_dns_parse_and_set_dns_str(
buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr, buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr,
ARES_RR_HINFO_CPU); ARES_RR_HINFO_CPU, ARES_TRUE);
if (status != ARES_SUCCESS) { if (status != ARES_SUCCESS) {
return status; return status;
} }
@ -263,7 +269,7 @@ static ares_status_t ares_dns_parse_rr_hinfo(ares__buf_t *buf,
/* OS */ /* OS */
status = ares_dns_parse_and_set_dns_str( status = ares_dns_parse_and_set_dns_str(
buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr, buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr,
ARES_RR_HINFO_OS); ARES_RR_HINFO_OS, ARES_TRUE);
return status; return status;
} }
@ -360,7 +366,7 @@ static ares_status_t ares_dns_parse_rr_naptr(ares__buf_t *buf,
/* FLAGS */ /* FLAGS */
status = ares_dns_parse_and_set_dns_str( status = ares_dns_parse_and_set_dns_str(
buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr, buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr,
ARES_RR_NAPTR_FLAGS); ARES_RR_NAPTR_FLAGS, ARES_TRUE);
if (status != ARES_SUCCESS) { if (status != ARES_SUCCESS) {
return status; return status;
} }
@ -368,7 +374,7 @@ static ares_status_t ares_dns_parse_rr_naptr(ares__buf_t *buf,
/* SERVICES */ /* SERVICES */
status = ares_dns_parse_and_set_dns_str( status = ares_dns_parse_and_set_dns_str(
buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr, buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr,
ARES_RR_NAPTR_SERVICES); ARES_RR_NAPTR_SERVICES, ARES_TRUE);
if (status != ARES_SUCCESS) { if (status != ARES_SUCCESS) {
return status; return status;
} }
@ -376,7 +382,7 @@ static ares_status_t ares_dns_parse_rr_naptr(ares__buf_t *buf,
/* REGEXP */ /* REGEXP */
status = ares_dns_parse_and_set_dns_str( status = ares_dns_parse_and_set_dns_str(
buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr, buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr,
ARES_RR_NAPTR_REGEXP); ARES_RR_NAPTR_REGEXP, ARES_TRUE);
if (status != ARES_SUCCESS) { if (status != ARES_SUCCESS) {
return status; return status;
} }
@ -656,7 +662,7 @@ static ares_status_t ares_dns_parse_rr_caa(ares__buf_t *buf, ares_dns_rr_t *rr,
/* Tag */ /* Tag */
status = ares_dns_parse_and_set_dns_str( status = ares_dns_parse_and_set_dns_str(
buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr, buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr,
ARES_RR_CAA_TAG); ARES_RR_CAA_TAG, ARES_FALSE);
if (status != ARES_SUCCESS) { if (status != ARES_SUCCESS) {
return status; return status;
} }

Loading…
Cancel
Save