Commit 55312eab authored by baire's avatar baire
Browse files

raise an error when a field is duplicated

parent 9bfa0067
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -760,7 +760,25 @@ void MessageHeader::PreDecodeField (Buffer& buffer) throw (DecodeError)

	if (reg_header_name.Match (buffer))
	{
		int id = SipHeaderMap::GetByName(reg_header_name.GetMatchedString (1)).mIdMessageHeader;
		const SipHeaderMap::Entry& hdr = SipHeaderMap::GetByName(reg_header_name.GetMatchedString (1));
		int id = hdr.mIdMessageHeader;

		// check that this field is not duplicated
		if (IsPresent(id)) {
			switch (id) {
			case id_accept:
			case id_contact:
			case id_via:
			case id_undefinedHeader_List:
				// these fields can appear multiple times
				break;
			default:
				DecodeError e (this);
				e.Msg() << "Duplicated field in the message: "
					<< hdr.mName << std::endl; 
				throw (e);
			}
		}
	
		SetHypNextField (id);
	} else {
@@ -1593,7 +1611,7 @@ void ViaBody::PreDecodeField (int id, Buffer& buffer) throw (DecodeError)

void ViaBody_List::PreDecode (Buffer& buffer) throw (DecodeError)
{
	// we assume that we are decoding one field at onece 
	// we assume that we are decoding one field at once 
	// multiple fields are handled by successively decoding
	// the via field several times in MessageHeader
	SetHypSize (GetSize() + 1);
@@ -1613,7 +1631,7 @@ void ViaBody_List::PostDecodeField (int id, Buffer& buffer) throw (DecodeError)

void UndefinedHeader_List::PreDecode (Buffer& buffer) throw (DecodeError)
{
	// we assume that we are decoding one field at onece 
	// we assume that we are decoding one field at once 
	// multiple fields are handled by successively decoding
	// the via field several times in MessageHeader
	SetHypSize (GetSize() + 1);