[tor-bugs] #8415 [Core Tor/Tor]: Use event_set_mem_functions

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Sep 6 19:01:23 UTC 2018


#8415: Use event_set_mem_functions
------------------------------------------+--------------------------------
 Reporter:  nickm                         |          Owner:  rl1987
     Type:  enhancement                   |         Status:  needs_revision
 Priority:  Medium                        |      Milestone:  Tor:
                                          |  0.3.5.x-final
Component:  Core Tor/Tor                  |        Version:
 Severity:  Normal                        |     Resolution:
 Keywords:  easy backend libevent malloc  |  Actual Points:
Parent ID:                                |         Points:
 Reviewer:                                |        Sponsor:
------------------------------------------+--------------------------------

Comment (by rl1987):

 It seems that `CRYPTO_set_mem_ex_functions` is no longer present in modern
 OpenSSL. I added a call to `CRYPTO_set_mem_functions` in
 fd9d51c5fce9d2a3539c2f18665c3af1a8941d58.

 However, on my Vagrant VM (which has OpenSSL 1.1.0f) there are following
 compiler warnings:
 {{{
 src/core/mainloop/main.c: In function ‘tor_run_main’:
 src/core/mainloop/main.c:4240:28: warning: passing argument 1 of
 ‘CRYPTO_set_mem_functions’ from incompatible pointer type [-Wincompatible-
 pointer-types]
    CRYPTO_set_mem_functions(tor_malloc_,
                             ^~~~~~~~~~~
 In file included from /usr/include/openssl/bn.h:33:0,
                  from /usr/include/openssl/engine.h:23,
                  from ./src/lib/crypt_ops/crypto_openssl_mgt.h:17,
                  from ./src/lib/crypt_ops/crypto_curve25519.h:15,
                  from ./src/lib/crypt_ops/crypto_ed25519.h:14,
                  from ./src/core/or/channel.h:15,
                  from src/core/mainloop/main.c:56:
 /usr/include/openssl/crypto.h:262:5: note: expected ‘void * (*)(size_t,
 const char *, int) {aka void * (*)(long unsigned int,  const char *,
 int)}’ but argument is of type ‘void * (*)(size_t) {aka void * (*)(long
 unsigned int)}’
  int CRYPTO_set_mem_functions(
      ^~~~~~~~~~~~~~~~~~~~~~~~
 src/core/mainloop/main.c:4241:28: warning: passing argument 2 of
 ‘CRYPTO_set_mem_functions’ from incompatible pointer type [-Wincompatible-
 pointer-types]
                             tor_realloc_,
                             ^~~~~~~~~~~~
 In file included from /usr/include/openssl/bn.h:33:0,
                  from /usr/include/openssl/engine.h:23,
                  from ./src/lib/crypt_ops/crypto_openssl_mgt.h:17,
                  from ./src/lib/crypt_ops/crypto_curve25519.h:15,
                  from ./src/lib/crypt_ops/crypto_ed25519.h:14,
                  from ./src/core/or/channel.h:15,
                  from src/core/mainloop/main.c:56:
 /usr/include/openssl/crypto.h:262:5: note: expected ‘void * (*)(void *,
 size_t,  const char *, int) {aka void * (*)(void *, long unsigned int,
 const char *, int)}’ but argument is of type ‘void * (*)(void *, size_t)
 {aka void * (*)(void *, long unsigned int)}’
  int CRYPTO_set_mem_functions(
      ^~~~~~~~~~~~~~~~~~~~~~~~
 src/core/mainloop/main.c:4242:28: warning: passing argument 3 of
 ‘CRYPTO_set_mem_functions’ from incompatible pointer type [-Wincompatible-
 pointer-types]
                             tor_free_);
                             ^~~~~~~~~
 In file included from /usr/include/openssl/bn.h:33:0,
                  from /usr/include/openssl/engine.h:23,
                  from ./src/lib/crypt_ops/crypto_openssl_mgt.h:17,
                  from ./src/lib/crypt_ops/crypto_curve25519.h:15,
                  from ./src/lib/crypt_ops/crypto_ed25519.h:14,
                  from ./src/core/or/channel.h:15,
                  from src/core/mainloop/main.c:56:
 /usr/include/openssl/crypto.h:262:5: note: expected ‘void (*)(void *,
 const char *, int)’ but argument is of type ‘void (*)(void *)’
  int CRYPTO_set_mem_functions(
      ^~~~~~~~~~~~~~~~~~~~~~~~
 }}}

 Do we disregard these? It compiles without warnings on macOS (OpenSSL
 1.1.0i) and on CI. OpenSSL declares their memory management functions with
 `char *` arguments, which is weird.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/8415#comment:16>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list