From 35750c3d11653f555f1e8b09c6758ba00c0833d5 Mon Sep 17 00:00:00 2001 From: "David A. Burgess" Date: Fri, 2 Jul 2010 18:18:00 -0700 Subject: [PATCH] Fix parsing error for malformed mobile identity types. --- public-trunk/GSM/GSML3CommonElements.cpp | 46 ++++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/public-trunk/GSM/GSML3CommonElements.cpp b/public-trunk/GSM/GSML3CommonElements.cpp index 0357441..d8f90cb 100644 --- a/public-trunk/GSM/GSML3CommonElements.cpp +++ b/public-trunk/GSM/GSML3CommonElements.cpp @@ -28,6 +28,7 @@ +#include #include "GSML3CommonElements.h" @@ -191,30 +192,29 @@ void L3MobileIdentity::parseV( const L3Frame& src, size_t &rp, size_t expectedLe bool oddCount = (bool) src.readField(rp,1); mType = (MobileIDType) src.readField(rp,3); - // No ID? - if (mType==NoIDType) { - mDigits[0]='\0'; - return; + switch (mType) { + case TMSIType: + mDigits[0]='\0'; + // GSM 03.03 2.4 tells us the TMSI is always 32 bits + mTMSI = src.readField(rp,32); + break; + case IMSIType: + case IMEISVType: + case IMEIType: + while (rp15) L3_READ_ERROR; + } + if (!oddCount) numDigits--; + mDigits[numDigits]='\0'; + break; + default: + LOG(NOTICE) << "non-standard identity type " << (int)mType; + mDigits[0]='\0'; + mType = NoIDType; } - - // TMSI? - if (mType==TMSIType) { - mDigits[0]='\0'; - // GSM 03.03 2.4 tells us the TMSI is always 32 bits - mTMSI = src.readField(rp,32); - return; - } - - // IMEI and IMSI. - while (rp15) L3_READ_ERROR; - } - if (!oddCount) numDigits--; - mDigits[numDigits]='\0'; - } void L3MobileIdentity::text(ostream& os) const