From f7fdfb8dda812c5f02bcc8a116b6f7f785e7f705 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 13 Aug 2016 08:09:13 +0200 Subject: [PATCH] EAP packet type check moved to Main.cpp --- EAPMethods/src/Main.cpp | 4 +++- lib/TTLS/src/Method.cpp | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/EAPMethods/src/Main.cpp b/EAPMethods/src/Main.cpp index d8ff11b..5d11cfe 100644 --- a/EAPMethods/src/Main.cpp +++ b/EAPMethods/src/Main.cpp @@ -366,8 +366,10 @@ DWORD APIENTRY EapPeerProcessRequestPacket( if (!hSession) g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL."))); - else if (!pReceivedPacket || dwReceivedPacketSize < 4) + else if (!pReceivedPacket || dwReceivedPacketSize < 6) g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pReceivedPacket is NULL or too short."))); + else if (pReceivedPacket->Data[0] != EAPMETHOD_TYPE) + g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, wstring_printf(_T(__FUNCTION__) _T(" Packet EAP type (%d) does not match the supported EAP type (%d)."), (int)pReceivedPacket->Data[0], (int)EAPMETHOD_TYPE).c_str())); else if (!pEapOutput) g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapOutput is NULL."))); else { diff --git a/lib/TTLS/src/Method.cpp b/lib/TTLS/src/Method.cpp index 7e23fd8..c5fdf86 100644 --- a/lib/TTLS/src/Method.cpp +++ b/lib/TTLS/src/Method.cpp @@ -86,12 +86,6 @@ void eap::method_ttls::process_request_packet( _In_ DWORD dwReceivedPacketSize, _Inout_ EapPeerMethodOutput *pEapOutput) { - // Is this a valid EAP-TTLS packet? - if (dwReceivedPacketSize < 6) - throw win_runtime_error(EAP_E_EAPHOST_METHOD_INVALID_PACKET, __FUNCTION__ " Packet is too small. EAP-%s packets should be at least 6B."); - else if (pReceivedPacket->Data[0] != eap_type_ttls) - throw win_runtime_error(EAP_E_EAPHOST_METHOD_INVALID_PACKET, string_printf(__FUNCTION__ " Packet is not EAP-TTLS (expected: %u, received: %u).", eap_type_ttls, pReceivedPacket->Data[0])); - if (pReceivedPacket->Code == EapCodeRequest && (pReceivedPacket->Data[1] & flags_start)) { // This is a start EAP-TTLS packet.