]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-esp.c
Haiku is a supported platform. [skip ci]
[tcpdump] / print-esp.c
index 14885d6b693b3ad088e8d462b3d5cd72123ca6df..61c3e13bffdae2da778ca29f5732f5929a22aaff 100644 (file)
@@ -347,7 +347,7 @@ static void esp_print_addsa(netdissect_options *ndo,
        nsa = (struct sa_list *)malloc(sizeof(struct sa_list));
        if (nsa == NULL)
                (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
-                                 "esp_print_addsa: malloc");
+                                 "%s: malloc", __func__);
 
        *nsa = *sa;
 
@@ -603,8 +603,8 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
                secretfile = fopen(filename, FOPEN_READ_TXT);
                if (secretfile == NULL) {
                        (*ndo->ndo_error)(ndo, S_ERR_ND_OPEN_FILE,
-                                         "print_esp: can't open %s: %s\n",
-                                         filename, strerror(errno));
+                                         "%s: can't open %s: %s\n",
+                                         __func__, filename, strerror(errno));
                }
 
                while (fgets(fileline, sizeof(fileline)-1, secretfile) != NULL) {
@@ -880,7 +880,7 @@ esp_print(netdissect_options *ndo,
        if (!nd_push_buffer(ndo, pt, pt, ep)) {
                free(pt);
                (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,
-                       "esp_print: can't push buffer on buffer stack");
+                       "%s: can't push buffer on buffer stack", __func__);
        }
 
        /*
@@ -903,12 +903,20 @@ esp_print(netdissect_options *ndo,
 
        ND_PRINT(": ");
 
+       /*
+        * Don't put padding + padding length(1 byte) + next header(1 byte)
+        * in the buffer because they are not part of the plaintext to decode.
+        */
+       nd_push_snapend(ndo, ep - (padlen + 2));
+
        /* Now dissect the plaintext. */
        ip_demux_print(ndo, pt, payloadlen - (padlen + 2), ver, fragmented,
-           ttl_hl, nh, bp2);
+                      ttl_hl, nh, bp2);
 
        /* Pop the buffer, freeing it. */
        nd_pop_packet_info(ndo);
+       /* Pop the nd_push_snapend */
+       nd_pop_packet_info(ndo);
 #endif
 }
 #ifdef HAVE_LIBCRYPTO