Browse code

Exclude peer-id from pulled options digest

v2:
- Use md5_* methods
- 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: <1475610786-25781-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12598.html

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

Lev Stipakov authored on 2016/10/05 04:53:06
Showing 1 changed files
... ...
@@ -407,6 +407,20 @@ push_reset (struct options *o)
407 407
 }
408 408
 #endif
409 409
 
410
+static void
411
+push_update_digest(struct md5_state *ctx, struct buffer *buf)
412
+{
413
+  char line[OPTION_PARM_SIZE];
414
+  while (buf_parse (buf, ',', line, sizeof (line)))
415
+    {
416
+      /* peer-id might change on restart and this should not trigger reopening tun */
417
+      if (strstr (line, "peer-id ") != line)
418
+	{
419
+	  md5_state_update (ctx, line, strlen(line));
420
+	}
421
+    }
422
+}
423
+
410 424
 int
411 425
 process_incoming_push_msg (struct context *c,
412 426
 			   const struct buffer *buffer,
... ...
@@ -473,20 +487,21 @@ process_incoming_push_msg (struct context *c,
473 473
 				  permission_mask,
474 474
 				  option_types_found,
475 475
 				  c->c2.es))
476
-	    switch (c->options.push_continuation)
477
-	      {
478
-	      case 0:
479
-	      case 1:
480
-		md5_state_update (&c->c2.pulled_options_state, BPTR(&buf_orig), BLEN(&buf_orig));
481
-		md5_state_final (&c->c2.pulled_options_state, &c->c2.pulled_options_digest);
482
-	        c->c2.pulled_options_md5_init_done = false;
483
-		ret = PUSH_MSG_REPLY;
484
-		break;
485
-	      case 2:
486
-		md5_state_update (&c->c2.pulled_options_state, BPTR(&buf_orig), BLEN(&buf_orig));
487
-		ret = PUSH_MSG_CONTINUATION;
488
-		break;
489
-	      }
476
+	    {
477
+	      push_update_digest (&c->c2.pulled_options_state, &buf_orig);
478
+	      switch (c->options.push_continuation)
479
+		{
480
+		  case 0:
481
+		  case 1:
482
+		    md5_state_final (&c->c2.pulled_options_state, &c->c2.pulled_options_digest);
483
+		    c->c2.pulled_options_md5_init_done = false;
484
+		    ret = PUSH_MSG_REPLY;
485
+		    break;
486
+		  case 2:
487
+		    ret = PUSH_MSG_CONTINUATION;
488
+		    break;
489
+		}
490
+	    }
490 491
 	}
491 492
       else if (ch == '\0')
492 493
 	{