Module: kamailio
Branch: master
Commit: cc0b07d2bcadbd95b2f0dbfdcc873306acca8f2d
URL:
https://github.com/kamailio/kamailio/commit/cc0b07d2bcadbd95b2f0dbfdcc87330…
Author: AndreasHuber-CH <andreas.huber(a)nagra.com>
Committer: AndreasHuber-CH <andreas.huber(a)nagra.com>
Date: 2016-07-26T08:41:20+02:00
registrar: Add warnings if contact is invalid and REGISTER will be rejected
Added some warnings in case a REGISTER is rejected because of an invalid contact header
field.
Before, kamailio might answer a 400 Bad Request for a too long contact URI for example
without logging any message.
---
Modified: modules/registrar/sip_msg.c
---
Diff:
https://github.com/kamailio/kamailio/commit/cc0b07d2bcadbd95b2f0dbfdcc87330…
Patch:
https://github.com/kamailio/kamailio/commit/cc0b07d2bcadbd95b2f0dbfdcc87330…
---
diff --git a/modules/registrar/sip_msg.c b/modules/registrar/sip_msg.c
index 36c4682..8856ce4 100644
--- a/modules/registrar/sip_msg.c
+++ b/modules/registrar/sip_msg.c
@@ -154,12 +154,14 @@ int check_contacts(struct sip_msg* _m, int* _s)
/* The first Contact HF is star */
/* Expires must be zero */
if (get_expires_hf(_m) != 0) {
+ LM_WARN("expires must be 0 for star contact\n");
rerrno = R_STAR_EXP;
return 1;
}
/* Message must contain no contacts */
if (((contact_body_t*)_m->contact->parsed)->contacts) {
+ LM_WARN("star contact cannot be mixed with other contacts\n");
rerrno = R_STAR_CONT;
return 1;
}
@@ -168,6 +170,7 @@ int check_contacts(struct sip_msg* _m, int* _s)
p = _m->contact->next;
while(p) {
if (p->type == HDR_CONTACT_T) {
+ LM_WARN("star contact cannot be mixed with other contacts\n");
rerrno = R_STAR_CONT;
return 1;
}
@@ -181,13 +184,19 @@ int check_contacts(struct sip_msg* _m, int* _s)
while(p) {
if (p->type == HDR_CONTACT_T) {
if (((contact_body_t*)p->parsed)->star == 1) {
+ LM_WARN("star contact cannot be mixed with other contacts\n");
rerrno = R_STAR_CONT;
return 1;
}
- /* check also the lenght of all contacts */
+ /* check also the length of all contacts */
for(c=((contact_body_t*)p->parsed)->contacts ; c ; c=c->next) {
- if (c->uri.len > CONTACT_MAX_SIZE
- || (c->received && c->received->len>RECEIVED_MAX_SIZE) ) {
+ if (c->uri.len > CONTACT_MAX_SIZE) {
+ LM_WARN("contact uri is too long: [%.*s]\n", c->uri.len,
c->uri.s);
+ rerrno = R_CONTACT_LEN;
+ return 1;
+ }
+ if (c->received && c->received->len>RECEIVED_MAX_SIZE) {
+ LM_WARN("received attribute of contact is too long\n");
rerrno = R_CONTACT_LEN;
return 1;
}