]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix the error handling of put_yamlstr calls
authorMark Andrews <marka@isc.org>
Wed, 30 Apr 2025 05:37:56 +0000 (15:37 +1000)
committerMark Andrews <marka@isc.org>
Wed, 30 Apr 2025 05:39:52 +0000 (15:39 +1000)
The return value was sometimes being ignored when it shouldn't
have been.

lib/dns/message.c

index 17e3e83e3aef9f2f5cf90565fcb141d54a0c1613..9eaeb990f01cc5652cc534ef49d76892208163bc 100644 (file)
@@ -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 {