]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Add maximum to received frame streams frames.
authorRalph Dolmans <ralph@nlnetlabs.nl>
Tue, 14 Jul 2020 12:29:09 +0000 (14:29 +0200)
committerRalph Dolmans <ralph@nlnetlabs.nl>
Tue, 14 Jul 2020 12:29:09 +0000 (14:29 +0200)
dnstap/dtstream.c

index f5fae08dc4609686beb117c7bccbaa8207ba89ff..030b66eeed0d75a0505ca20eb0e9e0092598b32f 100644 (file)
@@ -69,6 +69,9 @@
 /** the msec to wait for reconnect slow, to stop busy spinning on reconnect */
 #define DTIO_RECONNECT_TIMEOUT_SLOW 1000
 
+/** maximum length of received frame */
+#define DTIO_RECV_FRAME_MAX_LEN 1000
+
 struct stop_flush_info;
 /** DTIO command channel commands */
 enum {
@@ -1031,6 +1034,12 @@ static int dtio_read_accept_frame(struct dt_io_thread* dtio)
                        continue;
                }
                dtio->read_frame.frame_len = ntohl(dtio->read_frame.frame_len);
+               if(dtio->read_frame.frame_len > DTIO_RECV_FRAME_MAX_LEN) {
+                       verbose(VERB_OPS, "dnstap: received frame exceeds max "
+                               "length, capped to %d bytes",
+                               DTIO_RECV_FRAME_MAX_LEN);
+                       dtio->read_frame.frame_len = DTIO_RECV_FRAME_MAX_LEN;
+               }
                dtio->read_frame.buf = calloc(1, dtio->read_frame.frame_len);
                dtio->read_frame.buf_cap = dtio->read_frame.frame_len;
                if(!dtio->read_frame.buf) {