Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-570

C/C uses CRYPTO_THREADID_set_callback from openssl API

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.1
    • 3.3.0, 3.2.5, 3.1.15
    • None
    • None

    Description

      C/C uses CRYPTO_THREADID_set_callback() as

      ...
         CRYPTO_THREADID_set_callback(my_cb_threadid);
      ...
         CRYPTO_THREADID_set_callback(NULL);
      ...
      

      this is in openssl.c, the first line works on load, the second — on unload.

      But if you look in the openssl-1.0.2 code, you'll see

      int CRYPTO_THREADID_set_callback(void (*func) (CRYPTO_THREADID *))
      {
          if (threadid_callback)
              return 0;
          threadid_callback = func;
      

      that is, CRYPTO_THREADID_set_callback(NULL) does not remove the callback, in fact there is no way to remove the callback after it's set.

      This means that a shared library should never ever use CRYPTO_THREADID_set_callback(), because after the shared library is unloaded the callback will point into unallocated memory, and the callback, again, can never be removed.

      Attachments

        Activity

          georg Georg Richter added a comment -

          It affects only versions of OpenSSL <= 1.0.2 (eol).
          I think it is safe to remove the callback: if not set OpenSSL uses internal implementation (for Posix address of errno, for Windows GetCurrentThreadId).

          georg Georg Richter added a comment - It affects only versions of OpenSSL <= 1.0.2 (eol). I think it is safe to remove the callback: if not set OpenSSL uses internal implementation (for Posix address of errno, for Windows GetCurrentThreadId).

          Yes, agree, better to remove it completely.

          SLES12 still uses OpenSSL 1.0.2, so any application dynamically loading C/C there might be affected.

          serg Sergei Golubchik added a comment - Yes, agree, better to remove it completely. SLES12 still uses OpenSSL 1.0.2, so any application dynamically loading C/C there might be affected.

          People

            georg Georg Richter
            serg Sergei Golubchik
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.