mirror of https://github.com/wolfSSL/wolfssl.git
Fix for sniffer to ensure the session was polled before trying to reprocess it.
parent
9db4ae64b9
commit
9d2ed67a5c
|
@ -459,6 +459,9 @@ typedef struct Flags {
|
||||||
#endif
|
#endif
|
||||||
byte gotFinished; /* processed finished */
|
byte gotFinished; /* processed finished */
|
||||||
byte secRenegEn; /* secure renegotiation enabled */
|
byte secRenegEn; /* secure renegotiation enabled */
|
||||||
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
|
byte wasPolled;
|
||||||
|
#endif
|
||||||
} Flags;
|
} Flags;
|
||||||
|
|
||||||
|
|
||||||
|
@ -6392,6 +6395,14 @@ static int ssl_DecodePacketInternal(const byte* packet, int length, int isChain,
|
||||||
return 0; /* done for now */
|
return 0; /* done for now */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
|
/* make sure this server was polled */
|
||||||
|
if (asyncOkay && session->sslServer->error == WC_PENDING_E &&
|
||||||
|
!session->flags.wasPolled) {
|
||||||
|
return WC_PENDING_E;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WOLFSSL_SNIFFER_STATS
|
#ifdef WOLFSSL_SNIFFER_STATS
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
if (session->sslServer->error != WC_PENDING_E)
|
if (session->sslServer->error != WC_PENDING_E)
|
||||||
|
@ -6419,6 +6430,7 @@ static int ssl_DecodePacketInternal(const byte* packet, int length, int isChain,
|
||||||
session->pendSeq = tcpInfo.sequence;
|
session->pendSeq = tcpInfo.sequence;
|
||||||
|
|
||||||
if (ret == WC_PENDING_E) {
|
if (ret == WC_PENDING_E) {
|
||||||
|
session->flags.wasPolled = 0;
|
||||||
if (!asyncOkay || CryptoDeviceId == INVALID_DEVID) {
|
if (!asyncOkay || CryptoDeviceId == INVALID_DEVID) {
|
||||||
/* If devId has not been set then we need to block here by
|
/* If devId has not been set then we need to block here by
|
||||||
* polling and looping */
|
* polling and looping */
|
||||||
|
@ -6819,11 +6831,28 @@ int ssl_DecodePacketAsync(void* packet, unsigned int packetSz,
|
||||||
userCtx, error, 1);
|
userCtx, error, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SnifferSession* FindSession(WOLFSSL* ssl)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
SnifferSession* session;
|
||||||
|
for (i = 0; i < HASH_SIZE; i++) {
|
||||||
|
session = SessionTable[i];
|
||||||
|
while (session) {
|
||||||
|
if (session->sslServer == ssl) {
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
session = session->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int ssl_PollSniffer(WOLF_EVENT** events, int maxEvents, WOLF_EVENT_FLAG flags,
|
int ssl_PollSniffer(WOLF_EVENT** events, int maxEvents, WOLF_EVENT_FLAG flags,
|
||||||
int* pEventCount)
|
int* pEventCount)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int eventCount = 0;
|
int eventCount = 0;
|
||||||
|
int i;
|
||||||
SnifferServer* srv;
|
SnifferServer* srv;
|
||||||
|
|
||||||
wc_LockMutex(&ServerListMutex);
|
wc_LockMutex(&ServerListMutex);
|
||||||
|
@ -6848,8 +6877,21 @@ int ssl_PollSniffer(WOLF_EVENT** events, int maxEvents, WOLF_EVENT_FLAG flags,
|
||||||
}
|
}
|
||||||
srv = srv->next;
|
srv = srv->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
wc_UnLockMutex(&ServerListMutex);
|
wc_UnLockMutex(&ServerListMutex);
|
||||||
|
|
||||||
|
|
||||||
|
/* iterate list and mark polled */
|
||||||
|
wc_LockMutex(&SessionMutex);
|
||||||
|
for (i=0; i<eventCount; i++) {
|
||||||
|
WOLFSSL* ssl = (WOLFSSL*)events[i]->context;
|
||||||
|
SnifferSession* session = FindSession(ssl);
|
||||||
|
if (session) {
|
||||||
|
session->flags.wasPolled = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wc_UnLockMutex(&SessionMutex);
|
||||||
|
|
||||||
*pEventCount = eventCount;
|
*pEventCount = eventCount;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -522,6 +522,7 @@ static int SnifferAsyncQueueAdd(int lastRet, void* chain, int chainSz,
|
||||||
asyncQueue[ret].lastRet = lastRet;
|
asyncQueue[ret].lastRet = lastRet;
|
||||||
asyncQueue[ret].packetNumber = packetNumber;
|
asyncQueue[ret].packetNumber = packetNumber;
|
||||||
}
|
}
|
||||||
|
(void)isChain;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue