]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-quic.c
Avoid -E and -M options inconsistencies with no libcrypto
[tcpdump] / print-quic.c
index be1a5450ea62425528b2813af3c3dd1701975fb2..5e50c369e89680a1975bb711e09f87e94899eb79 100644 (file)
@@ -23,9 +23,7 @@
 /* \summary: QUIC Protocol printer */
 /* specification: https://www.rfc-editor.org/rfc/rfc9000.txt */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 #include "netdissect-alloc.h"
@@ -226,7 +224,8 @@ quic_print_packet(netdissect_options *ndo, const u_char *bp, const u_char *end)
                        }
                        if (packet_type == QUIC_LH_TYPE_RETRY) {
                                ND_PRINT(", token ");
-                               if (end > bp && end - bp > 16) {
+                               if (end > bp && end - bp > 16 &&
+                                   ND_TTEST_LEN(bp, end - bp - 16)) {
                                        token_length = end - bp - 16;
                                        token = nd_malloc(ndo, (size_t)token_length);
                                        GET_CPY_BYTES(token, bp, (size_t)token_length);
@@ -252,7 +251,8 @@ quic_print_packet(netdissect_options *ndo, const u_char *bp, const u_char *end)
        } else {
                /* Short Header */
                ND_PRINT(", protected");
-               if (ND_TTEST_LEN(bp, 16)) {
+               if (end > bp && end - bp > 16 &&
+                   ND_TTEST_LEN(bp, end - bp)) {
                        struct quic_cid_array *cid_array =
                                lookup_quic_cid(bp, end - bp);
                        if (cid_array != NULL) {
@@ -270,9 +270,9 @@ quic_print_packet(netdissect_options *ndo, const u_char *bp, const u_char *end)
 }
 
 void
-quic_print(netdissect_options *ndo, const u_char *bp, const u_int len)
+quic_print(netdissect_options *ndo, const u_char *bp)
 {
-       const uint8_t *end = bp + len;
+       const uint8_t *end = bp + ND_BYTES_AVAILABLE_AFTER(bp);
 
        ndo->ndo_protocol = "quic";
        nd_print_protocol(ndo);