Commit f3a57d9b authored by baire's avatar baire
Browse files

use the value of the Content-Length as a prediction when decoding the message...

use the value of the Content-Length as a prediction when decoding the message body to ensure that the content length does not mismatch
parent 808fd3a2
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -1847,15 +1847,26 @@ void ContentType::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)
	
}

void ContentLength::PostDecode (Buffer& buffer) throw (DecodeError)
{
	int l = Get_len().GetValue();
	MessageBody::SetHypLength ((l > 0) ? (l * 8) : -1);
}

#define SIP_MESSAGE_CODET(msgname) \
void msgname::PostDecodeField (int id, Buffer& buffer) throw (DecodeError) \
{ \
	switch (id) { \
	case id_msgHeader: \
		SetHypFieldIsPresent (id_messageBody, buffer.GetBitsLeft() ? 1 : 0); \
		SetHypFieldIsPresent (id_messageBody, (MessageBody::GetHypLength() >= 0) ? 1 : 0); \
		SetHypFieldIsPresent (id_payload, 0); \
		break; \
	case id_payload: \
		if (buffer.GetBitsLeft()) { \
			DecodeError ex(this); \
			ex.Msg() << "buffer not fully decoded (" << buffer.GetBitsLeft()/8 << " remaining bytes)" << std::endl; \
			throw ex; \
		} \
		Get_payload().Get_payloadlength().SetValue(buffer.GetLength() / 8); \
		Get_payload().Get_payloadvalue().SetValueBin(buffer.GetValueBin(), buffer.GetLength()); \
		break; \