From f4f5cba43dc1ed11bb97329cd2a6bc43e5e35d43 Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 11 Apr 2025 21:45:17 +0000 Subject: [PATCH] Avoid copying link-layer header; point instead --- libnetutil/netutil.h | 2 +- tcpip.cc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libnetutil/netutil.h b/libnetutil/netutil.h index c34f986ed..3b15c922f 100644 --- a/libnetutil/netutil.h +++ b/libnetutil/netutil.h @@ -237,7 +237,7 @@ typedef enum { devt_ethernet, devt_loopback, devt_p2p, devt_other } devtype; struct link_header { int datalinktype; /* pcap_datalink(), such as DLT_EN10MB */ int headerlen; /* 0 if header was too big or unavailaable */ - u8 header[MAX_LINK_HEADERSZ]; + const u8 *header; }; /* Relevant (to Nmap) information about an interface */ diff --git a/tcpip.cc b/tcpip.cc index f704dcf72..e38d20c15 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -1554,8 +1554,7 @@ const u8 *readip_pcap(pcap_t *pd, unsigned int *len, long to_usec, if (offset && linknfo) { linknfo->datalinktype = datalink; linknfo->headerlen = offset; - assert(offset <= MAX_LINK_HEADERSZ); - memcpy(linknfo->header, p - offset, MIN(sizeof(linknfo->header), offset)); + linknfo->header = p; } if (rcvdtime) PacketTrace::trace(PacketTrace::RCVD, (u8 *) p, *len,