From 5937fe57a8dea3298963247c0399749d7065eaf2 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Sun, 1 Mar 2020 10:16:08 +0100 Subject: hello_ext: use 64-bit integer to track extensions We currently have 26 predefined extensions, allowing the user to define 5 extra as tested in tests/handshake-large-packet.c. However, if we introduce one more, session->internals.used_exts exceeds. Signed-off-by: Daiki Ueno --- lib/gnutls_int.h | 6 +++--- lib/hello_ext.c | 2 +- lib/hello_ext.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h index d9d851be62..058fce090c 100644 --- a/lib/gnutls_int.h +++ b/lib/gnutls_int.h @@ -146,7 +146,7 @@ typedef int ssize_t; /* TLS Extensions */ /* we can receive up to MAX_EXT_TYPES extensions. */ -#define MAX_EXT_TYPES 32 +#define MAX_EXT_TYPES 64 /* TLS-internal extension (will be parsed after a ciphersuite is selected). * This amends the gnutls_ext_parse_type_t. Not exported yet to allow more refining @@ -358,8 +358,8 @@ typedef enum extensions_t { GNUTLS_EXTENSION_MAX /* not real extension - used for iterators */ } extensions_t; -#define GNUTLS_EXTENSION_MAX_VALUE 31 -#define ext_track_t uint32_t +#define GNUTLS_EXTENSION_MAX_VALUE 63 +#define ext_track_t uint64_t #if GNUTLS_EXTENSION_MAX >= GNUTLS_EXTENSION_MAX_VALUE # error over limit diff --git a/lib/hello_ext.c b/lib/hello_ext.c index 0c6c0dca01..1df1506e0b 100644 --- a/lib/hello_ext.c +++ b/lib/hello_ext.c @@ -520,7 +520,7 @@ int _gnutls_hello_ext_pack(gnutls_session_t session, gnutls_buffer_st *packed) BUFFER_APPEND_NUM(packed, 0); for (i = 0; i <= GNUTLS_EXTENSION_MAX_VALUE; i++) { - if (session->internals.used_exts & (1U << i)) { + if (session->internals.used_exts & ((ext_track_t)1 << i)) { ext = gid_to_ext_entry(session, i); if (ext == NULL) diff --git a/lib/hello_ext.h b/lib/hello_ext.h index 38b28ae069..a7b921875d 100644 --- a/lib/hello_ext.h +++ b/lib/hello_ext.h @@ -160,7 +160,7 @@ typedef struct hello_ext_entry_st { inline static unsigned _gnutls_hello_ext_is_present(gnutls_session_t session, extensions_t id) { - if (session->internals.used_exts & (1U << id)) + if (session->internals.used_exts & ((ext_track_t)1 << id)) return 1; return 0; @@ -184,7 +184,7 @@ unsigned _gnutls_hello_ext_save(gnutls_session_t session, return 0; } - session->internals.used_exts |= (1U << id); + session->internals.used_exts |= ((ext_track_t)1 << id); return 1; } -- cgit v1.2.1