]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_sip: Fix SUBSCRIBE with missing "Expires" header.
authorCorey Farrell <git@cfware.com>
Tue, 24 Oct 2017 14:43:15 +0000 (10:43 -0400)
committerCorey Farrell <git@cfware.com>
Tue, 24 Oct 2017 16:03:35 +0000 (11:03 -0500)
When chan_sip receives a SUBSCRIBE request with no "Expires" header it
processes the request as an unsubscribe.  This is incorrect, per RFC3264
when the "Expires" header is missing a default expiry should be used.

ASTERISK-18140

Change-Id: Ibf6dcd4fdd07a32c2bc38be1dd557981f08188b5

channels/chan_sip.c

index edaa38758072c981ea37c57f7df136b7927c4cdc..a615b68ab30c1b724fa65c45e44539b62dcebdbc 100644 (file)
@@ -28460,7 +28460,13 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
                p->lastinvite = seqno;
        }
        if (!p->needdestroy) {
-               p->expiry = atoi(sip_get_header(req, "Expires"));
+               const char *expires_str = sip_get_header(req, "Expires");
+
+               if (ast_strlen_zero(expires_str)) {
+                       p->expiry = default_expiry;
+               } else {
+                       p->expiry = atoi(expires_str);
+               }
 
                /* check if the requested expiry-time is within the approved limits from sip.conf */
                if (p->expiry > max_subexpiry) {