From d90ebf8e18a6376c15322fa513ae583b45066548 Mon Sep 17 00:00:00 2001 From: imguoliwei Date: Tue, 26 Apr 2022 15:40:13 +0800 Subject: [PATCH] fix TCP Timestamps --- src/ua2f-mix.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ua2f-mix.cpp b/src/ua2f-mix.cpp index b9f9122..0d99022 100644 --- a/src/ua2f-mix.cpp +++ b/src/ua2f-mix.cpp @@ -79,7 +79,9 @@ class TcpOptionsScanner { [[nodiscard]] bool hasNext() const { return curr < bound; } void next(){ - if(!hasNext()) throw std::out_of_range("TcpOptionsScanner out of bound"); + using std::out_of_range; + if(!hasNext()) throw out_of_range("TcpOptionsScanner out of bound"); + if(*curr == TCPOPT_EOL) throw out_of_range("TcpOptionsScanner's pointer reach end of option list"); if(*curr == TCPOPT_NOP){ ++curr; } else { @@ -217,6 +219,7 @@ static bool clearTcpTimestamps(pkt_buff *const pktb, const variantdoff * 4 == sizeof(tcphdr)) return false; for(TcpOptionsScanner optScanner(tcpPkHdl); optScanner.hasNext(); optScanner.next()){ auto const curr = optScanner.getCurrOption(); + if(*curr == TCPOPT_EOL) return false; if(*curr != TCPOPT_TIMESTAMP) continue; const unsigned int dataOffset = reinterpret_cast(tcpPkHdl) - ( isIPv4 ?