]> 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)
committerEvan Hunt <each@isc.org>
Wed, 7 May 2025 07:00:10 +0000 (00:00 -0700)
The return value was sometimes being ignored when it shouldn't
have been.

(cherry picked from commit c0fcb9fd0e1c4492ae695d9ef66f48cdeb6f7450)

lib/dns/message.c

index 65203c8cd1c707097ea67d87cc0cbef0412d8eed..80babc99a9ef17ca069e3d7abc9f3ebf83c9b572 100644 (file)
@@ -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 {