From ca125dca24d8ea6c48d813c8434367931b3283e9 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 30 Apr 2025 15:37:56 +1000 Subject: [PATCH] Fix the error handling of put_yamlstr calls The return value was sometimes being ignored when it shouldn't have been. (cherry picked from commit c0fcb9fd0e1c4492ae695d9ef66f48cdeb6f7450) --- lib/dns/message.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/dns/message.c b/lib/dns/message.c index 65203c8cd1..80babc99a9 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -103,6 +103,13 @@ hexdump(const char *msg, const char *msg2, void *base, size_t len) { } else \ isc_buffer_putstr(b, s); \ } +#define PUT_YAMLSTR(target, namebuf, len, utfok) \ + { \ + result = put_yamlstr(target, namebuf, len, utfok); \ + if (result != ISC_R_SUCCESS) { \ + goto cleanup; \ + } \ + } #define VALID_NAMED_PSEUDOSECTION(s) \ (((s) > DNS_PSEUDOSECTION_ANY) && ((s) < DNS_PSEUDOSECTION_MAX)) #define VALID_PSEUDOSECTION(s) \ @@ -3641,11 +3648,8 @@ render_nameopt(isc_buffer_t *optbuf, bool yaml, isc_buffer_t *target) { dns_name_format(name, namebuf, sizeof(namebuf)); ADD_STRING(target, " \""); if (yaml) { - result = put_yamlstr(target, (unsigned char *)namebuf, - strlen(namebuf), false); - if (result != ISC_R_SUCCESS) { - goto cleanup; - } + PUT_YAMLSTR(target, (unsigned char *)namebuf, + strlen(namebuf), false); } else { ADD_STRING(target, namebuf); } @@ -4059,7 +4063,7 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section, } else { ADD_STRING(target, "\""); } - put_yamlstr(target, optdata, optlen, utf8ok); + PUT_YAMLSTR(target, optdata, optlen, utf8ok); if (!extra_text) { ADD_STRING(target, "\")"); } else {