]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
reintroduce md5_digest wrapper struct to fix gcc warnings
authorSteffan Karger <steffan@karger.me>
Sun, 26 Jul 2015 11:27:19 +0000 (13:27 +0200)
committerGert Doering <gert@greenie.muc.de>
Mon, 27 Jul 2015 18:07:23 +0000 (20:07 +0200)
I was wrong to assume that adding the const qualifier to the pointer-to-
fixed-size-array contruction used in options_hash_changed_or_zero() was
allowed.  GCC actually warns about this, but I was using clang and clang
seems to be fine with the contruction.  To make GCC happy too, reintroduce
the md5_digest wrapped struct, and use that when passing around the digest.

This reverts the "struct md5_digest" parts of 827de237860813d2859a, but
keeps the rest.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1437910039-30101-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9949
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/crypto.h
src/openvpn/init.c
src/openvpn/openvpn.h
src/openvpn/push.c

index 504896dee13be7b34852296d9d832171e134c47d..b32a90018b1dfd222453de6f05df40e46c79ac53 100644 (file)
 #include "packet_id.h"
 #include "mtu.h"
 
+/** Wrapper struct to pass around MD5 digests */
+struct md5_digest {
+  uint8_t digest[MD5_DIGEST_LENGTH];
+};
+
 /*
  * Defines a key type and key length for both cipher and HMAC.
  */
index c24a646f366c0ef90a205b04cc1a1c0c90620f23..fe0091865bf84b6f765391d16ed07047e45b5efc 100644 (file)
@@ -1620,11 +1620,12 @@ tun_abort()
  * equal, or either one is all-zeroes.
  */
 static bool
-options_hash_changed_or_zero(const uint8_t (*a)[MD5_DIGEST_LENGTH],
-    const uint8_t (*b)[MD5_DIGEST_LENGTH])
+options_hash_changed_or_zero(const struct md5_digest *a,
+    const struct md5_digest *b)
 {
-  const uint8_t zero[MD5_DIGEST_LENGTH] = {0};
-  return memcmp (*a, *b, MD5_DIGEST_LENGTH) || memcmp (*a, zero, MD5_DIGEST_LENGTH);
+  const struct md5_digest zero = {{0}};
+  return memcmp (a, b, sizeof(struct md5_digest)) ||
+      memcmp (a, &zero, sizeof(struct md5_digest));
 }
 #endif /* P2MP */
 
@@ -1668,8 +1669,7 @@ do_up (struct context *c, bool pulled_options, unsigned int option_types_found)
       if (c->c2.did_open_tun)
        {
 #if P2MP
-         memcpy(c->c1.pulled_options_digest_save, c->c2.pulled_options_digest,
-             sizeof(c->c1.pulled_options_digest_save));
+         c->c1.pulled_options_digest_save = c->c2.pulled_options_digest;
 #endif
 
          /* if --route-delay was specified, start timer */
index ef7ca1d027fe66c3e2f8bf3e0afa99a637660a84..1c2a80b3528494625187a59d8f4650605179f6e8 100644 (file)
@@ -199,7 +199,7 @@ struct context_1
 #endif
 
   /* if client mode, hash of option strings we pulled from server */
-  uint8_t pulled_options_digest_save[MD5_DIGEST_LENGTH];
+  struct md5_digest pulled_options_digest_save;
                                 /**< Hash of option strings received from the
                                  *   remote OpenVPN server.  Only used in
                                  *   client-mode. */
@@ -465,7 +465,7 @@ struct context_2
   /* hash of pulled options, so we can compare when options change */
   bool pulled_options_md5_init_done;
   md_ctx_t pulled_options_state;
-  uint8_t pulled_options_digest[MD5_DIGEST_LENGTH];
+  struct md5_digest pulled_options_digest;
 
   struct event_timeout server_poll_interval;
 
index c99a097d1888c790881c728f1af5300e34f1dfcf..870616618d128c3e65c50fe6c4ba46ad88845ce4 100644 (file)
@@ -483,7 +483,7 @@ process_incoming_push_msg (struct context *c,
              case 0:
              case 1:
                md_ctx_update (&c->c2.pulled_options_state, BPTR(&buf_orig), BLEN(&buf_orig));
-               md_ctx_final (&c->c2.pulled_options_state, c->c2.pulled_options_digest);
+               md_ctx_final (&c->c2.pulled_options_state, c->c2.pulled_options_digest.digest);
                md_ctx_cleanup (&c->c2.pulled_options_state);
                c->c2.pulled_options_md5_init_done = false;
                ret = PUSH_MSG_REPLY;