]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
valgrind: check if session ticket key is used without initialization
authorDaiki Ueno <ueno@gnu.org>
Tue, 2 Jun 2020 19:45:17 +0000 (21:45 +0200)
committerDaiki Ueno <ueno@gnu.org>
Wed, 3 Jun 2020 07:04:53 +0000 (09:04 +0200)
This adds a valgrind client request for
session->key.session_ticket_key to make sure that it is not used
without initialization.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
lib/state.c
lib/stek.c

index 8ba2cc4a3228c518b8175ac9f5e97d182ba246cb..7d0a77dc95884bb956eb7ebc8bd6694c37d364ce 100644 (file)
@@ -578,9 +578,12 @@ int gnutls_init(gnutls_session_t * session, unsigned int flags)
                if (flags & GNUTLS_CLIENT)
                        VALGRIND_MAKE_MEM_UNDEFINED((*session)->security_parameters.client_random,
                                                    GNUTLS_RANDOM_SIZE);
-               if (flags & GNUTLS_SERVER)
+               if (flags & GNUTLS_SERVER) {
                        VALGRIND_MAKE_MEM_UNDEFINED((*session)->security_parameters.server_random,
                                                    GNUTLS_RANDOM_SIZE);
+                       VALGRIND_MAKE_MEM_UNDEFINED((*session)->key.session_ticket_key,
+                                                   TICKET_MASTER_KEY_SIZE);
+               }
        }
 #endif
        handshake_internal_state_clear1(*session);
index 5ab9e7d2d1ce10d7916f11b6851135e8772425ef..316555b49a8d996ecf8fd933b869ec1f7ea82d87 100644 (file)
@@ -21,6 +21,9 @@
  */
 #include "gnutls_int.h"
 #include "stek.h"
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
 
 #define NAME_POS (0)
 #define KEY_POS (TICKET_KEY_NAME_SIZE)
@@ -143,6 +146,11 @@ static int rotate(gnutls_session_t session)
                call_rotation_callback(session, key, t);
                session->key.totp.last_result = t;
                memcpy(session->key.session_ticket_key, key, sizeof(key));
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+               if (RUNNING_ON_VALGRIND)
+                       VALGRIND_MAKE_MEM_DEFINED(session->key.session_ticket_key,
+                                                 TICKET_MASTER_KEY_SIZE);
+#endif
 
                session->key.totp.was_rotated = 1;
        } else if (t < 0) {