Patch from dohmniq to properly increment the CSeq numbers in SIMPLE. release-2.x.y

Thu, 07 Apr 2022 22:33:38 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 07 Apr 2022 22:33:38 -0500
branch
release-2.x.y
changeset 41322
acd1360af5cb
parent 41272
17237faf35cb
child 41324
f20e9970a54f

Patch from dohmniq to properly increment the CSeq numbers in SIMPLE.

Testing Done:
Compiled

Bugs closed: PIDGIN-9675

Reviewed at https://reviews.imfreedom.org/r/1379/

COPYRIGHT file | annotate | diff | comparison | revisions
libpurple/protocols/simple/simple.c file | annotate | diff | comparison | revisions
--- a/COPYRIGHT	Fri Mar 04 00:08:27 2022 -0600
+++ b/COPYRIGHT	Thu Apr 07 22:33:38 2022 -0500
@@ -154,6 +154,7 @@
 Andrew Dieffenbach
 Ingmārs Dīriņš
 Finlay Dobbie
+dohmniq
 Mark Doliner
 Nuno Donato
 Jim Duchek
--- a/libpurple/protocols/simple/simple.c	Fri Mar 04 00:08:27 2022 -0600
+++ b/libpurple/protocols/simple/simple.c	Thu Apr 07 22:33:38 2022 -0500
@@ -620,6 +620,11 @@
 	if (cseq) {
 		while(transactions) {
 			trans = transactions->data;
+
+			purple_debug_info("simple",
+			                  "received CSeq %s vs known transaction CSeq %s\n",
+			                  cseq, trans->cseq);
+
 			if(purple_strequal(trans->cseq, cseq)) {
 				return trans;
 			}
@@ -1570,7 +1575,7 @@
 							/* This is encountered when a generic (MESSAGE, NOTIFY, etc)
 							 * was denied until further authorization is provided.
 							 */
-							gchar *resend, *auth;
+							gchar *resend, *auth, *cseq;
 							const gchar *ptmp;
 
 							if(sip->registrar.retries > SIMPLE_REGISTER_RETRY_MAX) return;
@@ -1583,10 +1588,22 @@
 							sipmsg_remove_header(trans->msg, "Authorization");
 							sipmsg_add_header(trans->msg, "Authorization", auth);
 							g_free(auth);
+
+							/* bump cseq */
+							sipmsg_remove_header(trans->msg, "CSeq");
+							sip->cseq++;
+							cseq = g_strdup_printf("%d %s", sip->cseq, trans->msg->method);
+							sipmsg_add_header(trans->msg, "CSeq", cseq);
+							g_free(cseq);
+							trans->cseq = sipmsg_find_header(trans->msg, "CSeq");
+
 							resend = sipmsg_to_string(trans->msg);
 							/* resend request */
 							sendout_pkt(sip->gc, resend);
 							g_free(resend);
+
+							/* exit here - no need to call callback, don't remove trans */
+							return;
 						} else {
 							/* Reset any count of retries that may have
 							 * accumulated in the above branch.

mercurial