Browse code

Exclude peer-id from pulled options digest

v2:
- Move digest update to separate method

Peer-id might change on restart and this should not trigger reopening
tun.

Trac #649
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1475612403-1266-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12599.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>

Lev Stipakov authored on 2016/10/05 05:20:03
Showing 1 changed files
... ...
@@ -597,6 +597,20 @@ process_incoming_push_request (struct context *c)
597 597
 }
598 598
 #endif
599 599
 
600
+static void
601
+push_update_digest(md_ctx_t *ctx, struct buffer *buf)
602
+{
603
+  char line[OPTION_PARM_SIZE];
604
+  while (buf_parse (buf, ',', line, sizeof (line)))
605
+    {
606
+      /* peer-id might change on restart and this should not trigger reopening tun */
607
+      if (strstr (line, "peer-id ") != line)
608
+	{
609
+	  md_ctx_update (ctx, (const uint8_t *) line, strlen(line));
610
+	}
611
+    }
612
+}
613
+
600 614
 int
601 615
 process_incoming_push_msg (struct context *c,
602 616
 			   const struct buffer *buffer,
... ...
@@ -636,21 +650,22 @@ process_incoming_push_msg (struct context *c,
636 636
 				  permission_mask,
637 637
 				  option_types_found,
638 638
 				  c->c2.es))
639
-	    switch (c->options.push_continuation)
640
-	      {
641
-	      case 0:
642
-	      case 1:
643
-		md_ctx_update (&c->c2.pulled_options_state, BPTR(&buf_orig), BLEN(&buf_orig));
644
-		md_ctx_final (&c->c2.pulled_options_state, c->c2.pulled_options_digest.digest);
645
-		md_ctx_cleanup (&c->c2.pulled_options_state);
646
-	        c->c2.pulled_options_md5_init_done = false;
647
-		ret = PUSH_MSG_REPLY;
648
-		break;
649
-	      case 2:
650
-		md_ctx_update (&c->c2.pulled_options_state, BPTR(&buf_orig), BLEN(&buf_orig));
651
-		ret = PUSH_MSG_CONTINUATION;
652
-		break;
653
-	      }
639
+	    {
640
+	      push_update_digest (&c->c2.pulled_options_state, &buf_orig);
641
+	      switch (c->options.push_continuation)
642
+		{
643
+		  case 0:
644
+		  case 1:
645
+		    md_ctx_final (&c->c2.pulled_options_state, c->c2.pulled_options_digest.digest);
646
+		    md_ctx_cleanup (&c->c2.pulled_options_state);
647
+		    c->c2.pulled_options_md5_init_done = false;
648
+		    ret = PUSH_MSG_REPLY;
649
+		    break;
650
+		  case 2:
651
+		    ret = PUSH_MSG_CONTINUATION;
652
+		    break;
653
+		}
654
+	    }
654 655
 	}
655 656
       else if (ch == '\0')
656 657
 	{