summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-09-11 10:25:51 +0000
committerBenny Prijono <bennylp@teluu.com>2008-09-11 10:25:51 +0000
commitf73a067f724263142faf534ccce94fa409bbb3f0 (patch)
tree3be5dac0493c04f05468837c7df36d9a38ec5868
parentb96da2717de701365dcb085e53879102e04e4232 (diff)
Ticket #623: Assertion when receiving SUBSCRIBE with non presence event (thanks Lucas Rosa Galêgo for the report)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2273 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip-apps/src/test-pjsua/scripts-sendto/500_pres_subscribe_with_bad_event.py28
-rw-r--r--pjsip/src/pjsua-lib/pjsua_pres.c15
2 files changed, 42 insertions, 1 deletions
diff --git a/pjsip-apps/src/test-pjsua/scripts-sendto/500_pres_subscribe_with_bad_event.py b/pjsip-apps/src/test-pjsua/scripts-sendto/500_pres_subscribe_with_bad_event.py
new file mode 100644
index 00000000..70f5ab94
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/scripts-sendto/500_pres_subscribe_with_bad_event.py
@@ -0,0 +1,28 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# Ticket http://trac.pjsip.org/repos/ticket/623, based on
+# http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2008-September/004709.html:
+#
+# Assertion when receiving SUBSCRIBE with non-presence Event.
+complete_msg = \
+"""SUBSCRIBE sip:localhost;transport=UDP SIP/2.0
+Call-ID: f20e8783e764cae325dba17be4b8fe19@10.0.2.15
+CSeq: 1 SUBSCRIBE
+From: <sip:localhost>;tag=1710895
+To: <sip:localhost>
+Via: SIP/2.0/UDP localhost;rport;branch=z9hG4bKd88a.18c427d2.0
+Max-Forwards: 69
+Event: message-summary
+Contact: <sip:localhost>
+Allow: NOTIFY, SUBSCRIBE
+Content-Length: 0
+
+"""
+
+
+sendto_cfg = sip.SendtoCfg( "Incoming SUBSCRIBE with non presence",
+ "--null-audio",
+ "", 489, complete_msg=complete_msg)
+
diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c
index f0a2100f..0e3cc211 100644
--- a/pjsip/src/pjsua-lib/pjsua_pres.c
+++ b/pjsip/src/pjsua-lib/pjsua_pres.c
@@ -718,9 +718,22 @@ static pj_bool_t pres_on_rx_request(pjsip_rx_data *rdata)
/* Create server presence subscription: */
status = pjsip_pres_create_uas( dlg, &pres_cb, rdata, &sub);
if (status != PJ_SUCCESS) {
- pjsip_dlg_terminate(dlg);
+ int code = PJSIP_ERRNO_TO_SIP_STATUS(status);
+ pjsip_tx_data *tdata;
+
pjsua_perror(THIS_FILE, "Unable to create server subscription",
status);
+
+ if (code==599 || code > 699 || code < 300) {
+ code = 400;
+ }
+
+ status = pjsip_dlg_create_response(dlg, rdata, code, NULL, &tdata);
+ if (status == PJ_SUCCESS) {
+ status = pjsip_dlg_send_response(dlg, pjsip_rdata_get_tsx(rdata),
+ tdata);
+ }
+
PJSUA_UNLOCK();
return PJ_TRUE;
}