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


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

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

ssl/ssl_lib.c:3926:1: start of procedure SSL_get_ex_data()
  3924.   }
  3925.   
  3926. > void *SSL_get_ex_data(const SSL *s, int idx)
  3927.   {
  3928.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:3928:5: 
  3926.   void *SSL_get_ex_data(const SSL *s, int idx)
  3927.   {
  3928. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  3929.   }
  3930.   

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

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

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

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

ssl/ssl_lib.c:3929:1: return from a call to SSL_get_ex_data
  3927.   {
  3928.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  3929. > }
  3930.   
  3931.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

ssl/ssl_lib.c:3763:1: start of procedure SSL_set_SSL_CTX()
  3761.   }
  3762.   
  3763. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3764.   {
  3765.       CERT *new_cert;

ssl/ssl_lib.c:3766:9: Taking false branch
  3764.   {
  3765.       CERT *new_cert;
  3766.       if (ssl->ctx == ctx)
                  ^
  3767.           return ssl->ctx;
  3768.       if (ctx == NULL)

ssl/ssl_lib.c:3768:9: Taking false branch
  3766.       if (ssl->ctx == ctx)
  3767.           return ssl->ctx;
  3768.       if (ctx == NULL)
                  ^
  3769.           ctx = ssl->session_ctx;
  3770.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3770:5: Skipping ssl_cert_dup(): empty list of specs
  3768.       if (ctx == NULL)
  3769.           ctx = ssl->session_ctx;
  3770.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3771.       if (new_cert == NULL) {
  3772.           return NULL;

ssl/ssl_lib.c:3771:9: Taking false branch
  3769.           ctx = ssl->session_ctx;
  3770.       new_cert = ssl_cert_dup(ctx->cert);
  3771.       if (new_cert == NULL) {
                  ^
  3772.           return NULL;
  3773.       }

ssl/ssl_lib.c:3775:10: Taking false branch
  3773.       }
  3774.   
  3775.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  3776.           ssl_cert_free(new_cert);
  3777.           return NULL;

ssl/ssl_lib.c:3780:5: 
  3778.       }
  3779.   
  3780. >     ssl_cert_free(ssl->cert);
  3781.       ssl->cert = new_cert;
  3782.   

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

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

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

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

ssl/ssl_lib.c:3781:5: 
  3779.   
  3780.       ssl_cert_free(ssl->cert);
  3781. >     ssl->cert = new_cert;
  3782.   
  3783.       /*

ssl/ssl_lib.c:3787:10: Condition is true
  3785.        * so setter APIs must prevent invalid lengths from entering the system.
  3786.        */
  3787.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3788.           return NULL;
  3789.   

ssl/ssl_lib.c:3787:10: Taking false branch
  3785.        * so setter APIs must prevent invalid lengths from entering the system.
  3786.        */
  3787.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3788.           return NULL;
  3789.   

ssl/ssl_lib.c:3796:10: Taking false branch
  3794.        * leave it unchanged.
  3795.        */
  3796.       if ((ssl->ctx != NULL) &&
                   ^
  3797.           (ssl->sid_ctx_length == ssl->ctx->sid_ctx_length) &&
  3798.           (memcmp(ssl->sid_ctx, ssl->ctx->sid_ctx, ssl->sid_ctx_length) == 0)) {

ssl/ssl_lib.c:3803:5: 
  3801.       }
  3802.   
  3803. >     SSL_CTX_up_ref(ctx);
  3804.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
  3805.       ssl->ctx = ctx;

ssl/ssl_lib.c:2917:1: start of procedure SSL_CTX_up_ref()
    2915.   }
    2916.   
    2917. > int SSL_CTX_up_ref(SSL_CTX *ctx)
    2918.   {
    2919.       int i;

ssl/ssl_lib.c:2921:9: 
    2919.       int i;
    2920.   
    2921. >     if (CRYPTO_UP_REF(&ctx->references, &i, ctx->lock) <= 0)
    2922.           return 0;
    2923.   

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:2921:9: Taking false branch
    2919.       int i;
    2920.   
    2921.       if (CRYPTO_UP_REF(&ctx->references, &i, ctx->lock) <= 0)
                    ^
    2922.           return 0;
    2923.   

ssl/ssl_lib.c:2926:14: Condition is false
    2924.       REF_PRINT_COUNT("SSL_CTX", ctx);
    2925.       REF_ASSERT_ISNT(i < 2);
    2926.       return ((i > 1) ? 1 : 0);
                         ^
    2927.   }
    2928.   

ssl/ssl_lib.c:2926:13: 
    2924.       REF_PRINT_COUNT("SSL_CTX", ctx);
    2925.       REF_ASSERT_ISNT(i < 2);
    2926. >     return ((i > 1) ? 1 : 0);
    2927.   }
    2928.   

ssl/ssl_lib.c:2926:5: 
    2924.       REF_PRINT_COUNT("SSL_CTX", ctx);
    2925.       REF_ASSERT_ISNT(i < 2);
    2926. >     return ((i > 1) ? 1 : 0);
    2927.   }
    2928.   

ssl/ssl_lib.c:2927:1: return from a call to SSL_CTX_up_ref
    2925.       REF_ASSERT_ISNT(i < 2);
    2926.       return ((i > 1) ? 1 : 0);
    2927. > }
    2928.   
    2929.   void SSL_CTX_free(SSL_CTX *a)

ssl/ssl_lib.c:3804:5: Skipping SSL_CTX_free(): empty list of specs
  3802.   
  3803.       SSL_CTX_up_ref(ctx);
  3804.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
              ^
  3805.       ssl->ctx = ctx;
  3806.   

ssl/ssl_lib.c:3805:5: 
  3803.       SSL_CTX_up_ref(ctx);
  3804.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
  3805. >     ssl->ctx = ctx;
  3806.   
  3807.       return ssl->ctx;

ssl/ssl_lib.c:3807:5: 
  3805.       ssl->ctx = ctx;
  3806.   
  3807. >     return ssl->ctx;
  3808.   }
  3809.   

ssl/ssl_lib.c:3808:1: return from a call to SSL_set_SSL_CTX
  3806.   
  3807.       return ssl->ctx;
  3808. > }
  3809.   
  3810.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

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

ssl/ssl_lib.c:4344:1: start of procedure SSL_clear_options()
  4342.   }
  4343.   
  4344. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4345.   {
  4346.       return s->options &= ~op;

ssl/ssl_lib.c:4346:5: 
  4344.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4345.   {
  4346. >     return s->options &= ~op;
  4347.   }
  4348.   

ssl/ssl_lib.c:4347:1: return from a call to SSL_clear_options
  4345.   {
  4346.       return s->options &= ~op;
  4347. > }
  4348.   
  4349.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

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

ssl/ssl_lib.c:4319:1: start of procedure SSL_CTX_get_options()
  4317.    * control interface.
  4318.    */
  4319. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4320.   {
  4321.       return ctx->options;

ssl/ssl_lib.c:4321:5: 
  4319.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4320.   {
  4321. >     return ctx->options;
  4322.   }
  4323.   

ssl/ssl_lib.c:4322:1: return from a call to SSL_CTX_get_options
  4320.   {
  4321.       return ctx->options;
  4322. > }
  4323.   
  4324.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4334:1: start of procedure SSL_set_options()
  4332.   }
  4333.   
  4334. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4335.   {
  4336.       return s->options |= op;

ssl/ssl_lib.c:4336:5: 
  4334.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4335.   {
  4336. >     return s->options |= op;
  4337.   }
  4338.   

ssl/ssl_lib.c:4337:1: return from a call to SSL_set_options
  4335.   {
  4336.       return s->options |= op;
  4337. > }
  4338.   
  4339.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

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