]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Exclude peer-id from pulled options digest
authorLev Stipakov <lstipakov@gmail.com>
Tue, 4 Oct 2016 19:53:06 +0000 (22:53 +0300)
committerGert Doering <gert@greenie.muc.de>
Mon, 10 Oct 2016 07:52:17 +0000 (09:52 +0200)
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>
src/openvpn/push.c

index 71f39c1ba1389cbd0914809841ba3c310fc69da2..402c15841a596fa27c1715f1f24d7b5789234c87 100644 (file)
@@ -407,6 +407,20 @@ push_reset (struct options *o)
 }
 #endif
 
+static void
+push_update_digest(struct md5_state *ctx, struct buffer *buf)
+{
+  char line[OPTION_PARM_SIZE];
+  while (buf_parse (buf, ',', line, sizeof (line)))
+    {
+      /* peer-id might change on restart and this should not trigger reopening tun */
+      if (strstr (line, "peer-id ") != line)
+       {
+         md5_state_update (ctx, line, strlen(line));
+       }
+    }
+}
+
 int
 process_incoming_push_msg (struct context *c,
                           const struct buffer *buffer,
@@ -473,20 +487,21 @@ process_incoming_push_msg (struct context *c,
                                  permission_mask,
                                  option_types_found,
                                  c->c2.es))
-           switch (c->options.push_continuation)
-             {
-             case 0:
-             case 1:
-               md5_state_update (&c->c2.pulled_options_state, BPTR(&buf_orig), BLEN(&buf_orig));
-               md5_state_final (&c->c2.pulled_options_state, &c->c2.pulled_options_digest);
-               c->c2.pulled_options_md5_init_done = false;
-               ret = PUSH_MSG_REPLY;
-               break;
-             case 2:
-               md5_state_update (&c->c2.pulled_options_state, BPTR(&buf_orig), BLEN(&buf_orig));
-               ret = PUSH_MSG_CONTINUATION;
-               break;
-             }
+           {
+             push_update_digest (&c->c2.pulled_options_state, &buf_orig);
+             switch (c->options.push_continuation)
+               {
+                 case 0:
+                 case 1:
+                   md5_state_final (&c->c2.pulled_options_state, &c->c2.pulled_options_digest);
+                   c->c2.pulled_options_md5_init_done = false;
+                   ret = PUSH_MSG_REPLY;
+                   break;
+                 case 2:
+                   ret = PUSH_MSG_CONTINUATION;
+                   break;
+               }
+           }
        }
       else if (ch == '\0')
        {