Skip to content

Fix preprocessor error in SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION

MacroFake requested to merge MacroFake/tor:master into main

SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION used to be 0x00040000U [1]. However, it recently changed to (uint64_t)0x00040000 [2] and then (uint64_t)1 << 18 [3].

The preprocessor can't parse the uint64_t token, so the whole expression fails to compile:

src/lib/tls/tortls_openssl.c:1198:3: warning: 'uint64_t' is not defined, evaluates to 0 [-Wundef]
  SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION != 0
  ^
/src/deps/include/openssl/ssl.h:388:58: note: expanded from macro 'SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION'
# define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION        SSL_OP_BIT(18)
                                                         ^
/src/deps/include/openssl/ssl.h:342:26: note: expanded from macro 'SSL_OP_BIT'
#define SSL_OP_BIT(n)  ((uint64_t)1 << (uint64_t)n)
                         ^
src/lib/tls/tortls_openssl.c:1198:3: error: token is not a valid binary operator in a preprocessor subexpression
  SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION != 0
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/src/deps/include/openssl/ssl.h:388:58: note: expanded from macro 'SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION'
# define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION        SSL_OP_BIT(18)
                                                         ^~~~~~~~~~~~~~
/src/deps/include/openssl/ssl.h:342:35: note: expanded from macro 'SSL_OP_BIT'
#define SSL_OP_BIT(n)  ((uint64_t)1 << (uint64_t)n)
                        ~~~~~~~~~~^
1 warning and 1 error generated.

Fix the issue by letting the compiler figure it out. I expect that this doesn't even change the resulting binary when compiled with a modern compiler and optimizations enabled.

SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION is always defined in this file, so the #if defined can be removed as well.

Merge request reports

Loading