Skip to content

Commit 1c2fb10

Browse files
authored
Merge pull request #9124 from dgarske/sniffer_partial_overlap
Fix for sniffer partial segment overlap that can occur when a TCP win…
2 parents 6ae0ecc + 8dd4307 commit 1c2fb10

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/sniffer.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5703,6 +5703,7 @@ static int AdjustSequence(TcpInfo* tcpInfo, SnifferSession* session,
57035703
TraceRelativeSequence(*expected, real);
57045704

57055705
if (real < *expected) {
5706+
int overlap = *expected - real;
57065707

57075708
if (real + *sslBytes > *expected) {
57085709
#ifdef WOLFSSL_ASYNC_CRYPT
@@ -5717,7 +5718,6 @@ static int AdjustSequence(TcpInfo* tcpInfo, SnifferSession* session,
57175718
* same action but for a different setup case. If changing this
57185719
* block be sure to also update the block below. */
57195720
if (reassemblyList) {
5720-
int overlap = *expected - real;
57215721
word32 newEnd;
57225722

57235723
/* adjust to expected, remove duplicate */
@@ -5746,11 +5746,17 @@ static int AdjustSequence(TcpInfo* tcpInfo, SnifferSession* session,
57465746
newEnd - reassemblyList->end, session, error);
57475747
}
57485748
}
5749-
else {
5750-
/* DUP overlap, allow */
5751-
if (*sslBytes > 0) {
5752-
skipPartial = 0; /* do not reset sslBytes */
5749+
else if (*sslBytes > 0) {
5750+
if (overlap < *sslBytes) {
5751+
/* adjust to remove partial overlap */
5752+
*sslFrame += overlap;
5753+
*sslBytes -= overlap;
57535754
}
5755+
else {
5756+
/* DUP overlap, allow */
5757+
}
5758+
5759+
skipPartial = 0; /* do not reset sslBytes */
57545760
}
57555761
ret = 0;
57565762
}
@@ -6417,7 +6423,7 @@ static int ProcessMessage(const byte* sslFrame, SnifferSession* session,
64176423
ivExtra = AESGCM_EXP_IV_SZ;
64186424
}
64196425

6420-
ret -= ivExtra;;
6426+
ret -= ivExtra;
64216427

64226428
#if defined(HAVE_ENCRYPT_THEN_MAC) && \
64236429
!defined(WOLFSSL_AEAD_ONLY)

0 commit comments

Comments
 (0)