Browse code

topoh: safety check for SIP messages

- received callback can be executed for non-sip messages
- reported by Julia
(cherry picked from commit 352a7dccf2570af857d7e2e50fed600c4762278d)
(cherry picked from commit 533f2238d9d14ed8ef0a367ce574aef8052c0452)

Daniel-Constantin Mierla authored on 26/05/2013 14:14:51
Showing 1 changed files
... ...
@@ -204,6 +204,18 @@ int th_prepare_msg(sip_msg_t *msg)
204 204
 		return 1;
205 205
 	}
206 206
 
207
+	if(msg->first_line.type==SIP_REQUEST)
208
+	{
209
+		if(!IS_SIP(msg))
210
+		{
211
+			LM_DBG("non sip request message\n");
212
+			return 1;
213
+		}
214
+	} else if(msg->first_line.type!=SIP_REPLY) {
215
+		LM_DBG("non sip message\n");
216
+		return 1;
217
+	}
218
+
207 219
 	if (parse_headers(msg, HDR_EOH_F, 0)==-1)
208 220
 	{
209 221
 		LM_DBG("parsing headers failed");