Browse code

sip: b/f: check method (ACK or PRACK) before deleting transaction

In case PRACK is received after 200, the transaction would be removed without checking the method.

Conflicts:

core/sip/trans_layer.cpp

Raphael Coeffic authored on 15/04/2014 12:49:49 • Stefan Sayer committed on 15/04/2014 20:31:17
Showing 1 changed files
... ...
@@ -1588,22 +1588,31 @@ int _trans_layer::update_uas_reply(trans_bucket* bucket, sip_trans* t, int reply
1588 1588
 int _trans_layer::update_uas_request(trans_bucket* bucket, sip_trans* t, sip_msg* msg)
1589 1589
 {
1590 1590
     DBG("update_uas_request(t=%p)\n", t);
1591
+    int method = msg->u.request->method;
1592
+
1593
+    if(method != sip_request::ACK &&
1594
+       method != sip_request::PRACK) {
1591 1595
 
1592
-    if(msg->u.request->method != sip_request::ACK &&
1593
-            msg->u.request->method != sip_request::PRACK){
1594 1596
 	ERROR("Bug? Recvd non PR-/ACK request for existing UAS transact.!?\n");
1595 1597
 	return -1;
1596 1598
     }
1597
-	
1599
+
1598 1600
     switch(t->state){
1599 1601
 
1602
+    case TS_PROCEEDING:
1603
+	// ACK or PRACK after non-reliable 1xx???
1604
+	return -1;
1605
+
1600 1606
     case TS_PROCEEDING_REL:
1601
-        // stop retransmissions
1602
-	t->clear_timer(STIMER_G);
1603
-	t->clear_timer(STIMER_H);
1607
+	if(method == sip_request::PRACK) {
1608
+	    // stop retransmissions
1609
+	    t->clear_timer(STIMER_G);
1610
+	    t->clear_timer(STIMER_H);
1611
+	}
1604 1612
         return t->state;
1605 1613
 	    
1606
-    case TS_COMPLETED:
1614
+    case TS_COMPLETED: // non-2xx-ACK
1615
+	if(method != sip_request::ACK) return -1;
1607 1616
 	t->state = TS_CONFIRMED;
1608 1617
 
1609 1618
 	t->clear_timer(STIMER_G);
... ...
@@ -1615,13 +1624,15 @@ int _trans_layer::update_uas_request(trans_bucket* bucket, sip_trans* t, sip_msg
1615 1624
     case TS_CONFIRMED:
1616 1625
 	return t->state;
1617 1626
 	    
1618
-    case TS_TERMINATED_200:
1627
+    case TS_TERMINATED_200: // 2xx-ACK
1628
+	if(method != sip_request::ACK) return -1;
1619 1629
 	// remove transaction
1620 1630
 	bucket->remove(t);
1621 1631
 	return TS_REMOVED;
1622 1632
 	    
1623 1633
     default:
1624 1634
 	DBG("Bug? Unknown state at this point: %i\n",t->state);
1635
+	break;
1625 1636
     }
1626 1637
 
1627 1638
     return -1;