]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix for testcode pktview to check buffer size and log errors.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 20 Mar 2026 14:57:46 +0000 (15:57 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 20 Mar 2026 14:57:46 +0000 (15:57 +0100)
doc/Changelog
testcode/pktview.c

index 396a2c3b69077642ff3b9be430fdf8896a4a6f01..f92de7fd0ba239200cad81bb670a1e994039fb2c 100644 (file)
@@ -1,3 +1,6 @@
+20 March 2026: Wouter
+       - Fix for testcode pktview to check buffer size and log errors.
+
 13 March 2026: Yorgos
        - Fix to ignore out-of-zone DNAME records for CNAME synthesis. Thanks
          to Yuxiao Wu, Yiyi Wang, Zhang Chao, Baojun Liu, and Haixin Duan from
index 12e0d8edbb68ff28e704d6f283c48145a92d3913..4cada926b5e68a288862dceeed7b46fc82c1efaf 100644 (file)
@@ -59,12 +59,16 @@ static void usage(char* argv[])
 /** read hex input */
 static void read_input(sldns_buffer* pkt, FILE* in)
 {
-       char buf[102400];
+       /* Buffer for 64Kib packet, in hex, with spaces and comments. */
+       char buf[1024000];
        char* np = buf;
        while(fgets(np, (int)sizeof(buf) - (np-buf), in)) {
                if(buf[0] == ';') /* comment */
                        continue;
                np = &np[strlen(np)];
+               if((size_t)(np-buf) >= sizeof(buf)-1)
+                       fatal_exit("input too large (%lu bytes)",
+                               (unsigned long)sizeof(buf));
        }
        hex_to_buf(pkt, buf);
 }
@@ -188,10 +192,16 @@ static void analyze(sldns_buffer* pkt)
 /** main program for pktview */
 int main(int argc, char* argv[]) 
 {
-       sldns_buffer* pkt = sldns_buffer_new(65553);
+       sldns_buffer* pkt;
+
+       log_init(NULL, 0, NULL);
+       log_ident_set("pktview");
+
        if(argc != 1) {
                usage(argv);
        }
+
+       pkt = sldns_buffer_new(65553);
        if(!pkt) fatal_exit("out of memory");
 
        read_input(pkt, stdin);