From: Mark Andrews Date: Wed, 30 Apr 2025 05:37:56 +0000 (+1000) Subject: Fix the error handling of put_yamlstr calls X-Git-Tag: v9.21.8~7^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0fcb9fd0e1c4492ae695d9ef66f48cdeb6f7450;p=thirdparty%2Fbind9.git Fix the error handling of put_yamlstr calls The return value was sometimes being ignored when it shouldn't have been. --- diff --git a/lib/dns/message.c b/lib/dns/message.c index 17e3e83e3ae..9eaeb990f01 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -102,6 +102,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) \ @@ -3500,11 +3507,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); } @@ -3574,11 +3578,8 @@ render_zoneversion(dns_message_t *msg, isc_buffer_t *optbuf, ADD_STRING(target, "ZONE: "); if (yaml) { ADD_STRING(target, "\""); - put_yamlstr(target, (unsigned char *)namebuf, + PUT_YAMLSTR(target, (unsigned char *)namebuf, strlen(namebuf), false); - if (result != ISC_R_SUCCESS) { - goto cleanup; - } ADD_STRING(target, "\""); } else { ADD_STRING(target, namebuf); @@ -3610,7 +3611,7 @@ render_zoneversion(dns_message_t *msg, isc_buffer_t *optbuf, ADD_STRING(target, sep2); INDENT(style); ADD_STRING(target, "PVALUE: \""); - put_yamlstr(target, data, len, false); + PUT_YAMLSTR(target, data, len, false); ADD_STRING(target, "\""); } else { ADD_STRING(target, " (\""); @@ -4030,7 +4031,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 {