Blob Blame History Raw
Fix broken Call-Disconnect-Notify code
Submitted upstream: http://marc.info/?l=pptpclient-devel&m=128594487715881&w=1

--- pptp-1.7.2/pptp_ctrl.c	2010-11-30 15:26:29.856391644 +0000
+++ pptp-1.7.2/pptp_ctrl.c	2010-11-30 15:26:29.861391766 +0000
@@ -941,15 +941,25 @@ int ctrlp_disp(PPTP_CONN * conn, void * 
         {
             struct pptp_call_clear_ntfy *packet =
                 (struct pptp_call_clear_ntfy *)buffer;
+            int i;
+            u_int16_t our_call_id;
+            u_int16_t peer_call_id = ntoh16(packet->call_id);
             log("Call disconnect notification received (call id %d)",
-                    ntoh16(packet->call_id));
-            if (vector_contains(conn->call, ntoh16(packet->call_id))) {
-                PPTP_CALL * call;
-                ctrlp_error(packet->result_code, packet->error_code,
-                        packet->cause_code, pptp_call_disc_ntfy,
-                        MAX_CALL_DISC_NTFY);
-                vector_search(conn->call, ntoh16(packet->call_id), &call);
-                pptp_call_destroy(conn, call);
+                (int) peer_call_id);
+            /* See if we can map the peer's call id to our own */
+            for (i = 0; i < vector_size(conn->call); i++) {
+                PPTP_CALL * call = vector_get_Nth(conn->call, i);
+                if (call->peer_call_id == peer_call_id) {
+                    our_call_id = call->call_id;
+                    if (vector_contains(conn->call, our_call_id)) {
+                        ctrlp_error(packet->result_code, packet->error_code,
+                            packet->cause_code, pptp_call_disc_ntfy,
+                            MAX_CALL_DISC_NTFY);
+                        vector_search(conn->call, our_call_id, &call);
+                        pptp_call_destroy(conn, call);
+                    }
+                    break;
+                }
             }
             /* XXX we could log call stats here XXX */
             /* XXX not all servers send this XXX */