]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Increase the BUFSIZ-long buffers
authorOndřej Surý <ondrej@isc.org>
Thu, 14 Jul 2022 11:48:45 +0000 (13:48 +0200)
committerOndřej Surý <ondrej@isc.org>
Fri, 15 Jul 2022 19:16:51 +0000 (21:16 +0200)
The BUFSIZ value varies between platforms, it could be 8K on Linux and
512 bytes on mingw.  Make sure the buffers are always big enough for the
output data to prevent truncation of the output by appropriately
enlarging or sizing the buffers.

(cherry picked from commit b19d932262e84608174cb89eeed32ae0212f8a87)

bin/named/server.c
bin/tests/system/feature-test.c
lib/dns/private.c
lib/ns/client.c

index 552434379e0c8929c0f307d3f48c163bf68a2190..4382902de5862eb6126f1cf0018e13c6098e4a6d 100644 (file)
@@ -15102,7 +15102,12 @@ named_server_signing(named_server_t *server, isc_lex_t *lex,
                     result = dns_rdataset_next(&privset))
                {
                        dns_rdata_t priv = DNS_RDATA_INIT;
-                       char output[BUFSIZ];
+                       /*
+                        * In theory, the output buffer could hold a full RDATA
+                        * record which is 16-bit and then some text around
+                        * it
+                        */
+                       char output[UINT16_MAX + BUFSIZ];
                        isc_buffer_t buf;
 
                        dns_rdataset_current(&privset, &priv);
index 30e6e14575ed9ced929ef92672425ae640825a4c..3435c91e07f7e962cd64f01d77e839aa82819582 100644 (file)
@@ -11,6 +11,7 @@
  * information regarding copyright ownership.
  */
 
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include <dns/edns.h>
 
-#ifndef MAXHOSTNAMELEN
-#ifdef HOST_NAME_MAX
-#define MAXHOSTNAMELEN HOST_NAME_MAX
-#else /* ifdef HOST_NAME_MAX */
-#define MAXHOSTNAMELEN 256
-#endif /* ifdef HOST_NAME_MAX */
-#endif /* ifndef MAXHOSTNAMELEN */
-
 static void
 usage(void) {
        fprintf(stderr, "usage: feature-test <arg>\n");
@@ -91,7 +84,7 @@ main(int argc, char **argv) {
        }
 
        if (strcmp(argv[1], "--gethostname") == 0) {
-               char hostname[MAXHOSTNAMELEN];
+               char hostname[_POSIX_HOST_NAME_MAX + 1];
                int n;
 
                n = gethostname(hostname, sizeof(hostname));
index 58deda095a969cb1e51385612b2a900403776821..cbf947f8cccb7a8c91d13b8b4add636b56c78418 100644 (file)
@@ -383,7 +383,8 @@ dns_private_totext(dns_rdata_t *private, isc_buffer_t *buf) {
        } else if (private->length == 5) {
                unsigned char alg = private->data[0];
                dns_keytag_t keyid = (private->data[2] | private->data[1] << 8);
-               char keybuf[BUFSIZ], algbuf[DNS_SECALG_FORMATSIZE];
+               char keybuf[DNS_SECALG_FORMATSIZE + BUFSIZ],
+                       algbuf[DNS_SECALG_FORMATSIZE];
                bool del = private->data[3];
                bool complete = private->data[4];
 
index 773d3de1757b17cdc360fd2504c8d8d91e22966f..393f35da621f00d042d603580f41a05c7eb33f27 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <inttypes.h>
+#include <limits.h>
 #include <stdbool.h>
 
 #include <isc/aes.h>
@@ -958,7 +959,7 @@ isc_result_t
 ns_client_addopt(ns_client_t *client, dns_message_t *message,
                 dns_rdataset_t **opt) {
        unsigned char ecs[ECS_SIZE];
-       char nsid[BUFSIZ], *nsidp = NULL;
+       char nsid[_POSIX_HOST_NAME_MAX + 1], *nsidp = NULL;
        unsigned char cookie[COOKIE_SIZE];
        isc_result_t result;
        dns_view_t *view = NULL;