Module: kamailio
Branch: master
Commit: 6208d8a0e31fa03ca24bc2fd63093607d235dbbd
URL: 
https://github.com/kamailio/kamailio/commit/6208d8a0e31fa03ca24bc2fd63093607d235dbbd

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2021-09-17T08:22:09+02:00

core: receive - check for required headers before routing blocks

---

Modified: src/core/receive.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/6208d8a0e31fa03ca24bc2fd63093607d235dbbd.diff
Patch: 
https://github.com/kamailio/kamailio/commit/6208d8a0e31fa03ca24bc2fd63093607d235dbbd.patch

---

diff --git a/src/core/receive.c b/src/core/receive.c
index f3b31fefbc..b3e6aee8b8 100644
--- a/src/core/receive.c
+++ b/src/core/receive.c
@@ -421,9 +421,13 @@ int receive_msg(char *buf, unsigned int len, 
receive_info_t *rcv_info)
        if(msg->first_line.type == SIP_REQUEST) {
                ruri_mark_new(); /* ruri is usable for forking (not consumed 
yet) */
                if(!IS_SIP(msg)) {
+                       LM_DBG("handling non-sip request message\n");
                        if((ret = nonsip_msg_run_hooks(msg)) != 
NONSIP_MSG_ACCEPT) {
-                               if(unlikely(ret == NONSIP_MSG_ERROR))
+                               if(unlikely(ret == NONSIP_MSG_ERROR)) {
+                                       LM_DBG("failed handling non-sip request 
message\n");
                                        goto error03;
+                               }
+                               LM_DBG("finished handling non-sip request 
message\n");
                                goto end; /* drop the message */
                        }
                }
@@ -435,6 +439,14 @@ int receive_msg(char *buf, unsigned int len, 
receive_info_t *rcv_info)
                        STATS_BAD_MSG();
                        goto error02;
                }
+               if(unlikely((msg->callid == 0) || (msg->cseq == 0) || 
(msg->from == 0)
+                                       || (msg->to == 0))) {
+                       /* no required headers -- send back error ? */
+                       LOG(cfg_get(core, core_cfg, sip_parser_log),
+                                       "required headers not found in 
request\n");
+                       STATS_BAD_MSG();
+                       goto error02;
+               }
 /* check if necessary to add receive?->moved to forward_req */
 /* check for the alias stuff */
 #ifdef USE_TCP
@@ -526,6 +538,14 @@ int receive_msg(char *buf, unsigned int len, 
receive_info_t *rcv_info)
                        STATS_BAD_RPL();
                        goto error02;
                }
+               if(unlikely((msg->callid == 0) || (msg->cseq == 0) || 
(msg->from == 0)
+                                       || (msg->to == 0))) {
+                       /* no required headers -- send back error ? */
+                       LOG(cfg_get(core, core_cfg, sip_parser_log),
+                                       "required headers not found in 
reply\n");
+                       STATS_BAD_RPL();
+                       goto error02;
+               }
 
                if(exectime) {
                        gettimeofday(&tvb, NULL);


_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to