test/handshake_helper.c:190: error: NULL_DEREFERENCE
  pointer `ex_data` last assigned on line 145 could be null and is dereferenced at line 190, column 9.
Showing all 71 steps of the trace


test/handshake_helper.c:140:1: start of procedure client_hello_select_server_ctx()
138.   }
139.   
140. > static int client_hello_select_server_ctx(SSL *s, void *arg, int ignore)
141.   {
142.       const char *servername;

test/handshake_helper.c:145:5: 
143.       const unsigned char *p;
144.       size_t len, remaining;
145. >     HANDSHAKE_EX_DATA *ex_data =
146.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
147.   

ssl/ssl_lib.c:3889:1: start of procedure SSL_get_ex_data()
  3887.   }
  3888.   
  3889. > void *SSL_get_ex_data(const SSL *s, int idx)
  3890.   {
  3891.       return (CRYPTO_get_ex_data(&s->ex_data, idx));

ssl/ssl_lib.c:3891:5: 
  3889.   void *SSL_get_ex_data(const SSL *s, int idx)
  3890.   {
  3891. >     return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3892.   }
  3893.   

crypto/ex_data.c:394:1: start of procedure CRYPTO_get_ex_data()
    392.    * particular index in the class used by this variable
    393.    */
    394. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    395.   {
    396.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))

crypto/ex_data.c:396:9: Taking true branch
    394.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    395.   {
    396.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
                   ^
    397.           return NULL;
    398.       return sk_void_value(ad->sk, idx);

crypto/ex_data.c:397:9: 
    395.   {
    396.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
    397. >         return NULL;
    398.       return sk_void_value(ad->sk, idx);
    399.   }

crypto/ex_data.c:399:1: return from a call to CRYPTO_get_ex_data
    397.           return NULL;
    398.       return sk_void_value(ad->sk, idx);
    399. > }

ssl/ssl_lib.c:3892:1: return from a call to SSL_get_ex_data
  3890.   {
  3891.       return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3892. > }
  3893.   
  3894.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

test/handshake_helper.c:152:10: Taking false branch
150.        * was written, so parsing the normal case is a bit complex.
151.        */
152.       if (!SSL_client_hello_get0_ext(s, TLSEXT_TYPE_server_name, &p,
                ^
153.                                      &remaining) ||
154.           remaining <= 2)

test/handshake_helper.c:154:9: Taking false branch
152.       if (!SSL_client_hello_get0_ext(s, TLSEXT_TYPE_server_name, &p,
153.                                      &remaining) ||
154.           remaining <= 2)
               ^
155.           return 0;
156.       /* Extract the length of the supplied list of names. */

test/handshake_helper.c:157:5: 
155.           return 0;
156.       /* Extract the length of the supplied list of names. */
157. >     len = (*(p++) << 8);
158.       len += *(p++);
159.       if (len + 2 != remaining)

test/handshake_helper.c:158:5: 
156.       /* Extract the length of the supplied list of names. */
157.       len = (*(p++) << 8);
158. >     len += *(p++);
159.       if (len + 2 != remaining)
160.           return 0;

test/handshake_helper.c:159:9: Taking false branch
157.       len = (*(p++) << 8);
158.       len += *(p++);
159.       if (len + 2 != remaining)
               ^
160.           return 0;
161.       remaining = len;

test/handshake_helper.c:161:5: 
159.       if (len + 2 != remaining)
160.           return 0;
161. >     remaining = len;
162.       /*
163.        * The list in practice only has a single element, so we only consider

test/handshake_helper.c:166:9: Taking false branch
164.        * the first one.
165.        */
166.       if (remaining == 0 || *p++ != TLSEXT_NAMETYPE_host_name)
               ^
167.           return 0;
168.       remaining--;

test/handshake_helper.c:166:27: Taking false branch
164.        * the first one.
165.        */
166.       if (remaining == 0 || *p++ != TLSEXT_NAMETYPE_host_name)
                                 ^
167.           return 0;
168.       remaining--;

test/handshake_helper.c:168:5: 
166.       if (remaining == 0 || *p++ != TLSEXT_NAMETYPE_host_name)
167.           return 0;
168. >     remaining--;
169.       /* Now we can finally pull out the byte array with the actual hostname. */
170.       if (remaining <= 2)

test/handshake_helper.c:170:9: Taking false branch
168.       remaining--;
169.       /* Now we can finally pull out the byte array with the actual hostname. */
170.       if (remaining <= 2)
               ^
171.           return 0;
172.       len = (*(p++) << 8);

test/handshake_helper.c:172:5: 
170.       if (remaining <= 2)
171.           return 0;
172. >     len = (*(p++) << 8);
173.       len += *(p++);
174.       if (len + 2 > remaining)

test/handshake_helper.c:173:5: 
171.           return 0;
172.       len = (*(p++) << 8);
173. >     len += *(p++);
174.       if (len + 2 > remaining)
175.           return 0;

test/handshake_helper.c:174:9: Taking false branch
172.       len = (*(p++) << 8);
173.       len += *(p++);
174.       if (len + 2 > remaining)
               ^
175.           return 0;
176.       remaining = len;

test/handshake_helper.c:176:5: 
174.       if (len + 2 > remaining)
175.           return 0;
176. >     remaining = len;
177.       servername = (const char *)p;
178.   

test/handshake_helper.c:177:5: 
175.           return 0;
176.       remaining = len;
177. >     servername = (const char *)p;
178.   
179.       if (len == strlen("server2") && strncmp(servername, "server2", len) == 0) {

test/handshake_helper.c:179:9: Taking true branch
177.       servername = (const char *)p;
178.   
179.       if (len == strlen("server2") && strncmp(servername, "server2", len) == 0) {
               ^
180.           SSL_CTX *new_ctx = arg;
181.           SSL_set_SSL_CTX(s, new_ctx);

test/handshake_helper.c:179:37: Taking true branch
177.       servername = (const char *)p;
178.   
179.       if (len == strlen("server2") && strncmp(servername, "server2", len) == 0) {
                                           ^
180.           SSL_CTX *new_ctx = arg;
181.           SSL_set_SSL_CTX(s, new_ctx);

test/handshake_helper.c:180:9: 
178.   
179.       if (len == strlen("server2") && strncmp(servername, "server2", len) == 0) {
180. >         SSL_CTX *new_ctx = arg;
181.           SSL_set_SSL_CTX(s, new_ctx);
182.           /*

test/handshake_helper.c:181:9: 
179.       if (len == strlen("server2") && strncmp(servername, "server2", len) == 0) {
180.           SSL_CTX *new_ctx = arg;
181. >         SSL_set_SSL_CTX(s, new_ctx);
182.           /*
183.            * Copy over all the SSL_CTX options - reasonable behavior

ssl/ssl_lib.c:3726:1: start of procedure SSL_set_SSL_CTX()
  3724.   }
  3725.   
  3726. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3727.   {
  3728.       CERT *new_cert;

ssl/ssl_lib.c:3729:9: Taking false branch
  3727.   {
  3728.       CERT *new_cert;
  3729.       if (ssl->ctx == ctx)
                  ^
  3730.           return ssl->ctx;
  3731.       if (ctx == NULL)

ssl/ssl_lib.c:3731:9: Taking false branch
  3729.       if (ssl->ctx == ctx)
  3730.           return ssl->ctx;
  3731.       if (ctx == NULL)
                  ^
  3732.           ctx = ssl->session_ctx;
  3733.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3733:5: Skipping ssl_cert_dup(): empty list of specs
  3731.       if (ctx == NULL)
  3732.           ctx = ssl->session_ctx;
  3733.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3734.       if (new_cert == NULL) {
  3735.           return NULL;

ssl/ssl_lib.c:3734:9: Taking false branch
  3732.           ctx = ssl->session_ctx;
  3733.       new_cert = ssl_cert_dup(ctx->cert);
  3734.       if (new_cert == NULL) {
                  ^
  3735.           return NULL;
  3736.       }

ssl/ssl_lib.c:3738:10: Taking false branch
  3736.       }
  3737.   
  3738.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  3739.           ssl_cert_free(new_cert);
  3740.           return NULL;

ssl/ssl_lib.c:3743:5: 
  3741.       }
  3742.   
  3743. >     ssl_cert_free(ssl->cert);
  3744.       ssl->cert = new_cert;
  3745.   

ssl/ssl_cert.c:225:1: start of procedure ssl_cert_free()
    223.   }
    224.   
    225. > void ssl_cert_free(CERT *c)
    226.   {
    227.       int i;

ssl/ssl_cert.c:229:9: Taking true branch
    227.       int i;
    228.   
    229.       if (c == NULL)
                   ^
    230.           return;
    231.   

ssl/ssl_cert.c:230:9: 
    228.   
    229.       if (c == NULL)
    230. >         return;
    231.   
    232.       CRYPTO_DOWN_REF(&c->references, &i, c->lock);

ssl/ssl_cert.c:255:1: return from a call to ssl_cert_free
    253.       CRYPTO_THREAD_lock_free(c->lock);
    254.       OPENSSL_free(c);
    255. > }
    256.   
    257.   int ssl_cert_set0_chain(SSL *s, SSL_CTX *ctx, STACK_OF(X509) *chain)

ssl/ssl_lib.c:3744:5: 
  3742.   
  3743.       ssl_cert_free(ssl->cert);
  3744. >     ssl->cert = new_cert;
  3745.   
  3746.       /*

ssl/ssl_lib.c:3750:10: Condition is true
  3748.        * so setter APIs must prevent invalid lengths from entering the system.
  3749.        */
  3750.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3751.           return NULL;
  3752.   

ssl/ssl_lib.c:3750:10: Taking false branch
  3748.        * so setter APIs must prevent invalid lengths from entering the system.
  3749.        */
  3750.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3751.           return NULL;
  3752.   

ssl/ssl_lib.c:3759:10: Taking false branch
  3757.        * leave it unchanged.
  3758.        */
  3759.       if ((ssl->ctx != NULL) &&
                   ^
  3760.           (ssl->sid_ctx_length == ssl->ctx->sid_ctx_length) &&
  3761.           (memcmp(ssl->sid_ctx, ssl->ctx->sid_ctx, ssl->sid_ctx_length) == 0)) {

ssl/ssl_lib.c:3766:5: 
  3764.       }
  3765.   
  3766. >     SSL_CTX_up_ref(ctx);
  3767.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
  3768.       ssl->ctx = ctx;

ssl/ssl_lib.c:2889:1: start of procedure SSL_CTX_up_ref()
    2887.   }
    2888.   
    2889. > int SSL_CTX_up_ref(SSL_CTX *ctx)
    2890.   {
    2891.       int i;

ssl/ssl_lib.c:2893:9: 
    2891.       int i;
    2892.   
    2893. >     if (CRYPTO_UP_REF(&ctx->references, &i, ctx->lock) <= 0)
    2894.           return 0;
    2895.   

include/internal/refcount.h:32:1: start of procedure CRYPTO_UP_REF()
      30.   typedef _Atomic int CRYPTO_REF_COUNT;
      31.   
      32. > static ossl_inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, void *lock)
      33.   {
      34.       *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;

include/internal/refcount.h:34:5: 
      32.   static ossl_inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, void *lock)
      33.   {
      34. >     *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;
      35.       return 1;
      36.   }

include/internal/refcount.h:35:5: 
      33.   {
      34.       *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;
      35. >     return 1;
      36.   }
      37.   

include/internal/refcount.h:36:1: return from a call to CRYPTO_UP_REF
      34.       *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;
      35.       return 1;
      36. > }
      37.   
      38.   static ossl_inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, void *lock)

ssl/ssl_lib.c:2893:9: Taking false branch
    2891.       int i;
    2892.   
    2893.       if (CRYPTO_UP_REF(&ctx->references, &i, ctx->lock) <= 0)
                    ^
    2894.           return 0;
    2895.   

ssl/ssl_lib.c:2898:14: Condition is false
    2896.       REF_PRINT_COUNT("SSL_CTX", ctx);
    2897.       REF_ASSERT_ISNT(i < 2);
    2898.       return ((i > 1) ? 1 : 0);
                         ^
    2899.   }
    2900.   

ssl/ssl_lib.c:2898:13: 
    2896.       REF_PRINT_COUNT("SSL_CTX", ctx);
    2897.       REF_ASSERT_ISNT(i < 2);
    2898. >     return ((i > 1) ? 1 : 0);
    2899.   }
    2900.   

ssl/ssl_lib.c:2898:5: 
    2896.       REF_PRINT_COUNT("SSL_CTX", ctx);
    2897.       REF_ASSERT_ISNT(i < 2);
    2898. >     return ((i > 1) ? 1 : 0);
    2899.   }
    2900.   

ssl/ssl_lib.c:2899:1: return from a call to SSL_CTX_up_ref
    2897.       REF_ASSERT_ISNT(i < 2);
    2898.       return ((i > 1) ? 1 : 0);
    2899. > }
    2900.   
    2901.   void SSL_CTX_free(SSL_CTX *a)

ssl/ssl_lib.c:3767:5: Skipping SSL_CTX_free(): empty list of specs
  3765.   
  3766.       SSL_CTX_up_ref(ctx);
  3767.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
              ^
  3768.       ssl->ctx = ctx;
  3769.   

ssl/ssl_lib.c:3768:5: 
  3766.       SSL_CTX_up_ref(ctx);
  3767.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
  3768. >     ssl->ctx = ctx;
  3769.   
  3770.       return ssl->ctx;

ssl/ssl_lib.c:3770:5: 
  3768.       ssl->ctx = ctx;
  3769.   
  3770. >     return ssl->ctx;
  3771.   }
  3772.   

ssl/ssl_lib.c:3771:1: return from a call to SSL_set_SSL_CTX
  3769.   
  3770.       return ssl->ctx;
  3771. > }
  3772.   
  3773.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

test/handshake_helper.c:187:9: 
185.            * contexts differ/conflict
186.            */
187. >         SSL_clear_options(s, 0xFFFFFFFFL);
188.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
189.   

ssl/ssl_lib.c:4307:1: start of procedure SSL_clear_options()
  4305.   }
  4306.   
  4307. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4308.   {
  4309.       return s->options &= ~op;

ssl/ssl_lib.c:4309:5: 
  4307.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4308.   {
  4309. >     return s->options &= ~op;
  4310.   }
  4311.   

ssl/ssl_lib.c:4310:1: return from a call to SSL_clear_options
  4308.   {
  4309.       return s->options &= ~op;
  4310. > }
  4311.   
  4312.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

test/handshake_helper.c:188:9: 
186.            */
187.           SSL_clear_options(s, 0xFFFFFFFFL);
188. >         SSL_set_options(s, SSL_CTX_get_options(new_ctx));
189.   
190.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;

ssl/ssl_lib.c:4282:1: start of procedure SSL_CTX_get_options()
  4280.    * control interface.
  4281.    */
  4282. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4283.   {
  4284.       return ctx->options;

ssl/ssl_lib.c:4284:5: 
  4282.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4283.   {
  4284. >     return ctx->options;
  4285.   }
  4286.   

ssl/ssl_lib.c:4285:1: return from a call to SSL_CTX_get_options
  4283.   {
  4284.       return ctx->options;
  4285. > }
  4286.   
  4287.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4297:1: start of procedure SSL_set_options()
  4295.   }
  4296.   
  4297. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4298.   {
  4299.       return s->options |= op;

ssl/ssl_lib.c:4299:5: 
  4297.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4298.   {
  4299. >     return s->options |= op;
  4300.   }
  4301.   

ssl/ssl_lib.c:4300:1: return from a call to SSL_set_options
  4298.   {
  4299.       return s->options |= op;
  4300. > }
  4301.   
  4302.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

test/handshake_helper.c:190:9: 
188.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
189.   
190. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
191.           return 1;
192.       } else if (len == strlen("server1") &&
