From: Evgeny Vereshchagin Date: Wed, 25 Oct 2023 18:15:42 +0000 Subject: tests: pass overly long TXT resource records to make sure they don't crash avahi any more. It reproduces https://github.com/lathiat/avahi/issues/455 (cherry picked from commit c6cab87df290448a63323c8ca759baa516166237) Origin: https://github.com/avahi/avahi/commit/c6cab87df290448a63323c8ca759baa516166237 --- avahi-client/client-test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/avahi-client/client-test.c b/avahi-client/client-test.c index 57750a4..2f51e3e 100644 --- a/avahi-client/client-test.c +++ b/avahi-client/client-test.c @@ -22,6 +22,7 @@ #endif #include +#include #include #include @@ -33,6 +34,8 @@ #include #include +#include + static const AvahiPoll *poll_api = NULL; static AvahiSimplePoll *simple_poll = NULL; @@ -222,6 +225,9 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { uint32_t cookie; struct timeval tv; AvahiAddress a; + uint8_t rdata[AVAHI_DNS_RDATA_MAX+1]; + AvahiStringList *txt = NULL; + int r; simple_poll = avahi_simple_poll_new(); poll_api = avahi_simple_poll_get(simple_poll); @@ -261,6 +267,14 @@ int main (AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { error = avahi_entry_group_add_record (group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "TestX", 0x01, 0x10, 120, "", 0); assert(error != AVAHI_OK); + memset(rdata, 1, sizeof(rdata)); + r = avahi_string_list_parse(rdata, sizeof(rdata), &txt); + assert(r >= 0); + assert(avahi_string_list_serialize(txt, NULL, 0) == sizeof(rdata)); + error = avahi_entry_group_add_service_strlst(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, "TestX", "_qotd._tcp", NULL, NULL, 123, txt); + assert(error == AVAHI_ERR_INVALID_RECORD); + avahi_string_list_free(txt); + avahi_entry_group_commit (group); domain = avahi_domain_browser_new (avahi, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, avahi_domain_browser_callback, (char*) "omghai3u");