From 991bcdba6eafb6c1c37086ac4ea722a7a14dcb9c Mon Sep 17 00:00:00 2001 From: Brad House Date: Sat, 11 Nov 2023 10:25:29 -0500 Subject: [PATCH] 0-length strings are ok --- src/lib/ares__buf.c | 19 ++++++++++--------- src/lib/ares_dns_parse.c | 5 +++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/lib/ares__buf.c b/src/lib/ares__buf.c index 1e928258..a54b3988 100644 --- a/src/lib/ares__buf.c +++ b/src/lib/ares__buf.c @@ -796,15 +796,16 @@ ares_status_t ares__buf_parse_dns_binstr(ares__buf_t *buf, size_t remaining_len, break; } - /* XXX: Maybe we should scan to make sure it is printable? */ - if (bin != NULL) { - status = ares__buf_fetch_bytes_into_buf(buf, binbuf, len); - } else { - status = ares__buf_consume(buf, len); - } - - if (status != ARES_SUCCESS) { - break; + if (len) { + /* XXX: Maybe we should scan to make sure it is printable? */ + if (bin != NULL) { + status = ares__buf_fetch_bytes_into_buf(buf, binbuf, len); + } else { + status = ares__buf_consume(buf, len); + } + if (status != ARES_SUCCESS) { + break; + } } if (!allow_multiple) { diff --git a/src/lib/ares_dns_parse.c b/src/lib/ares_dns_parse.c index a9caa695..01eaa9b6 100644 --- a/src/lib/ares_dns_parse.c +++ b/src/lib/ares_dns_parse.c @@ -261,9 +261,11 @@ static ares_status_t ares_dns_parse_rr_hinfo(ares__buf_t *buf, } /* OS */ - return 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, ARES_RR_HINFO_OS); + + return status; } static ares_status_t ares_dns_parse_rr_mx(ares__buf_t *buf, ares_dns_rr_t *rr, @@ -1085,7 +1087,6 @@ static ares_status_t ares_dns_parse_rr(ares__buf_t *buf, unsigned int flags, goto done; } - /* Determine how many bytes were processed */ processed_len = remaining_len - ares__buf_len(buf);