From be31ebf7d61d02d7d4767a17a0bcbc0eacb5a69e Mon Sep 17 00:00:00 2001 From: lotodore Date: Tue, 4 Aug 2009 07:26:18 +0000 Subject: [PATCH] Enable enforcing of network packet constraints. Did I mention asn1c is really cool? Anyway, some constraints are still wrong, so this breaks game creation. I will fix it this evening. --- src/net/common/receiverhelper.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/net/common/receiverhelper.cpp b/src/net/common/receiverhelper.cpp index 98f6c2a1..6c5141a0 100644 --- a/src/net/common/receiverhelper.cpp +++ b/src/net/common/receiverhelper.cpp @@ -54,7 +54,7 @@ ReceiverHelper::ScanPackets(ReceiveBuffer &buf) // This call will also handle the memmove stuff, i.e. // buffering for partial packets. tmpPacket = NetPacket::Create(buf.recvBuf, buf.recvBufUsed); - } catch (const NetException &e) + } catch (const exception &e) { // Reset buffer on error. buf.recvBufUsed = 0; @@ -64,7 +64,10 @@ ReceiverHelper::ScanPackets(ReceiveBuffer &buf) if (tmpPacket) { //cerr << "IN:" << endl << tmpPacket->ToString() << endl; - buf.receivedPackets.push_back(tmpPacket); + if (asn_check_constraints(&asn_DEF_PokerTHMessage, tmpPacket->GetMsg(), NULL, NULL) == 0) + buf.receivedPackets.push_back(tmpPacket); + else + LOG_ERROR("Invalid packet: " << endl << tmpPacket->ToString()); } else dataAvailable = false;