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


test/handshake_helper.c:146:1: start of procedure client_hello_select_server_ctx()
144.   }
145.   
146. > static int client_hello_select_server_ctx(SSL *s, void *arg, int ignore)
147.   {
148.       const char *servername;

test/handshake_helper.c:151:5: 
149.       const unsigned char *p;
150.       size_t len, remaining;
151. >     HANDSHAKE_EX_DATA *ex_data =
152.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
153.   

ssl/ssl_lib.c:4154:1: start of procedure SSL_get_ex_data()
  4152.   }
  4153.   
  4154. > void *SSL_get_ex_data(const SSL *s, int idx)
  4155.   {
  4156.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:4156:5: 
  4154.   void *SSL_get_ex_data(const SSL *s, int idx)
  4155.   {
  4156. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  4157.   }
  4158.   

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:4157:1: return from a call to SSL_get_ex_data
  4155.   {
  4156.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  4157. > }
  4158.   
  4159.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

test/handshake_helper.c:158:10: Taking false branch
156.        * was written, so parsing the normal case is a bit complex.
157.        */
158.       if (!SSL_client_hello_get0_ext(s, TLSEXT_TYPE_server_name, &p,
                ^
159.                                      &remaining) ||
160.           remaining <= 2)

test/handshake_helper.c:160:9: Taking false branch
158.       if (!SSL_client_hello_get0_ext(s, TLSEXT_TYPE_server_name, &p,
159.                                      &remaining) ||
160.           remaining <= 2)
               ^
161.           return 0;
162.       /* Extract the length of the supplied list of names. */

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

test/handshake_helper.c:164:5: 
162.       /* Extract the length of the supplied list of names. */
163.       len = (*(p++) << 8);
164. >     len += *(p++);
165.       if (len + 2 != remaining)
166.           return 0;

test/handshake_helper.c:165:9: Taking false branch
163.       len = (*(p++) << 8);
164.       len += *(p++);
165.       if (len + 2 != remaining)
               ^
166.           return 0;
167.       remaining = len;

test/handshake_helper.c:167:5: 
165.       if (len + 2 != remaining)
166.           return 0;
167. >     remaining = len;
168.       /*
169.        * The list in practice only has a single element, so we only consider

test/handshake_helper.c:172:9: Taking false branch
170.        * the first one.
171.        */
172.       if (remaining == 0 || *p++ != TLSEXT_NAMETYPE_host_name)
               ^
173.           return 0;
174.       remaining--;

test/handshake_helper.c:172:27: Taking false branch
170.        * the first one.
171.        */
172.       if (remaining == 0 || *p++ != TLSEXT_NAMETYPE_host_name)
                                 ^
173.           return 0;
174.       remaining--;

test/handshake_helper.c:174:5: 
172.       if (remaining == 0 || *p++ != TLSEXT_NAMETYPE_host_name)
173.           return 0;
174. >     remaining--;
175.       /* Now we can finally pull out the byte array with the actual hostname. */
176.       if (remaining <= 2)

test/handshake_helper.c:176:9: Taking false branch
174.       remaining--;
175.       /* Now we can finally pull out the byte array with the actual hostname. */
176.       if (remaining <= 2)
               ^
177.           return 0;
178.       len = (*(p++) << 8);

test/handshake_helper.c:178:5: 
176.       if (remaining <= 2)
177.           return 0;
178. >     len = (*(p++) << 8);
179.       len += *(p++);
180.       if (len + 2 > remaining)

test/handshake_helper.c:179:5: 
177.           return 0;
178.       len = (*(p++) << 8);
179. >     len += *(p++);
180.       if (len + 2 > remaining)
181.           return 0;

test/handshake_helper.c:180:9: Taking false branch
178.       len = (*(p++) << 8);
179.       len += *(p++);
180.       if (len + 2 > remaining)
               ^
181.           return 0;
182.       remaining = len;

test/handshake_helper.c:182:5: 
180.       if (len + 2 > remaining)
181.           return 0;
182. >     remaining = len;
183.       servername = (const char *)p;
184.   

test/handshake_helper.c:183:5: 
181.           return 0;
182.       remaining = len;
183. >     servername = (const char *)p;
184.   
185.       if (len == strlen("server2") && strncmp(servername, "server2", len) == 0) {

test/handshake_helper.c:185:9: Taking true branch
183.       servername = (const char *)p;
184.   
185.       if (len == strlen("server2") && strncmp(servername, "server2", len) == 0) {
               ^
186.           SSL_CTX *new_ctx = arg;
187.           SSL_set_SSL_CTX(s, new_ctx);

test/handshake_helper.c:185:37: Taking true branch
183.       servername = (const char *)p;
184.   
185.       if (len == strlen("server2") && strncmp(servername, "server2", len) == 0) {
                                           ^
186.           SSL_CTX *new_ctx = arg;
187.           SSL_set_SSL_CTX(s, new_ctx);

test/handshake_helper.c:186:9: 
184.   
185.       if (len == strlen("server2") && strncmp(servername, "server2", len) == 0) {
186. >         SSL_CTX *new_ctx = arg;
187.           SSL_set_SSL_CTX(s, new_ctx);
188.           /*

test/handshake_helper.c:187:9: 
185.       if (len == strlen("server2") && strncmp(servername, "server2", len) == 0) {
186.           SSL_CTX *new_ctx = arg;
187. >         SSL_set_SSL_CTX(s, new_ctx);
188.           /*
189.            * Copy over all the SSL_CTX options - reasonable behavior

ssl/ssl_lib.c:3991:1: start of procedure SSL_set_SSL_CTX()
  3989.   }
  3990.   
  3991. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3992.   {
  3993.       CERT *new_cert;

ssl/ssl_lib.c:3994:9: Taking false branch
  3992.   {
  3993.       CERT *new_cert;
  3994.       if (ssl->ctx == ctx)
                  ^
  3995.           return ssl->ctx;
  3996.       if (ctx == NULL)

ssl/ssl_lib.c:3996:9: Taking false branch
  3994.       if (ssl->ctx == ctx)
  3995.           return ssl->ctx;
  3996.       if (ctx == NULL)
                  ^
  3997.           ctx = ssl->session_ctx;
  3998.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3998:5: Skipping ssl_cert_dup(): empty list of specs
  3996.       if (ctx == NULL)
  3997.           ctx = ssl->session_ctx;
  3998.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3999.       if (new_cert == NULL) {
  4000.           return NULL;

ssl/ssl_lib.c:3999:9: Taking false branch
  3997.           ctx = ssl->session_ctx;
  3998.       new_cert = ssl_cert_dup(ctx->cert);
  3999.       if (new_cert == NULL) {
                  ^
  4000.           return NULL;
  4001.       }

ssl/ssl_lib.c:4003:10: Taking false branch
  4001.       }
  4002.   
  4003.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  4004.           ssl_cert_free(new_cert);
  4005.           return NULL;

ssl/ssl_lib.c:4008:5: Skipping ssl_cert_free(): empty list of specs
  4006.       }
  4007.   
  4008.       ssl_cert_free(ssl->cert);
              ^
  4009.       ssl->cert = new_cert;
  4010.   

ssl/ssl_lib.c:4009:5: 
  4007.   
  4008.       ssl_cert_free(ssl->cert);
  4009. >     ssl->cert = new_cert;
  4010.   
  4011.       /*

ssl/ssl_lib.c:4015:10: Condition is true
  4013.        * so setter APIs must prevent invalid lengths from entering the system.
  4014.        */
  4015.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  4016.           return NULL;
  4017.   

ssl/ssl_lib.c:4015:10: Taking false branch
  4013.        * so setter APIs must prevent invalid lengths from entering the system.
  4014.        */
  4015.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  4016.           return NULL;
  4017.   

ssl/ssl_lib.c:4024:10: Taking true branch
  4022.        * leave it unchanged.
  4023.        */
  4024.       if ((ssl->ctx != NULL) &&
                   ^
  4025.           (ssl->sid_ctx_length == ssl->ctx->sid_ctx_length) &&
  4026.           (memcmp(ssl->sid_ctx, ssl->ctx->sid_ctx, ssl->sid_ctx_length) == 0)) {

ssl/ssl_lib.c:4025:10: Taking false branch
  4023.        */
  4024.       if ((ssl->ctx != NULL) &&
  4025.           (ssl->sid_ctx_length == ssl->ctx->sid_ctx_length) &&
                   ^
  4026.           (memcmp(ssl->sid_ctx, ssl->ctx->sid_ctx, ssl->sid_ctx_length) == 0)) {
  4027.           ssl->sid_ctx_length = ctx->sid_ctx_length;

ssl/ssl_lib.c:4031:5: 
  4029.       }
  4030.   
  4031. >     SSL_CTX_up_ref(ctx);
  4032.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
  4033.       ssl->ctx = ctx;

ssl/ssl_lib.c:3125:1: start of procedure SSL_CTX_up_ref()
    3123.   }
    3124.   
    3125. > int SSL_CTX_up_ref(SSL_CTX *ctx)
    3126.   {
    3127.       int i;

ssl/ssl_lib.c:3129:9: 
    3127.       int i;
    3128.   
    3129. >     if (CRYPTO_UP_REF(&ctx->references, &i, ctx->lock) <= 0)
    3130.           return 0;
    3131.   

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:3129:9: Taking false branch
    3127.       int i;
    3128.   
    3129.       if (CRYPTO_UP_REF(&ctx->references, &i, ctx->lock) <= 0)
                    ^
    3130.           return 0;
    3131.   

ssl/ssl_lib.c:3134:14: Condition is false
    3132.       REF_PRINT_COUNT("SSL_CTX", ctx);
    3133.       REF_ASSERT_ISNT(i < 2);
    3134.       return ((i > 1) ? 1 : 0);
                         ^
    3135.   }
    3136.   

ssl/ssl_lib.c:3134:13: 
    3132.       REF_PRINT_COUNT("SSL_CTX", ctx);
    3133.       REF_ASSERT_ISNT(i < 2);
    3134. >     return ((i > 1) ? 1 : 0);
    3135.   }
    3136.   

ssl/ssl_lib.c:3134:5: 
    3132.       REF_PRINT_COUNT("SSL_CTX", ctx);
    3133.       REF_ASSERT_ISNT(i < 2);
    3134. >     return ((i > 1) ? 1 : 0);
    3135.   }
    3136.   

ssl/ssl_lib.c:3135:1: return from a call to SSL_CTX_up_ref
    3133.       REF_ASSERT_ISNT(i < 2);
    3134.       return ((i > 1) ? 1 : 0);
    3135. > }
    3136.   
    3137.   void SSL_CTX_free(SSL_CTX *a)

ssl/ssl_lib.c:4032:5: Skipping SSL_CTX_free(): empty list of specs
  4030.   
  4031.       SSL_CTX_up_ref(ctx);
  4032.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
              ^
  4033.       ssl->ctx = ctx;
  4034.   

ssl/ssl_lib.c:4033:5: 
  4031.       SSL_CTX_up_ref(ctx);
  4032.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
  4033. >     ssl->ctx = ctx;
  4034.   
  4035.       return ssl->ctx;

ssl/ssl_lib.c:4035:5: 
  4033.       ssl->ctx = ctx;
  4034.   
  4035. >     return ssl->ctx;
  4036.   }
  4037.   

ssl/ssl_lib.c:4036:1: return from a call to SSL_set_SSL_CTX
  4034.   
  4035.       return ssl->ctx;
  4036. > }
  4037.   
  4038.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

test/handshake_helper.c:193:9: 
191.            * contexts differ/conflict
192.            */
193. >         SSL_clear_options(s, 0xFFFFFFFFL);
194.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
195.   

ssl/ssl_lib.c:4578:1: start of procedure SSL_clear_options()
  4576.   }
  4577.   
  4578. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4579.   {
  4580.       return s->options &= ~op;

ssl/ssl_lib.c:4580:5: 
  4578.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4579.   {
  4580. >     return s->options &= ~op;
  4581.   }
  4582.   

ssl/ssl_lib.c:4581:1: return from a call to SSL_clear_options
  4579.   {
  4580.       return s->options &= ~op;
  4581. > }
  4582.   
  4583.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

test/handshake_helper.c:194:9: 
192.            */
193.           SSL_clear_options(s, 0xFFFFFFFFL);
194. >         SSL_set_options(s, SSL_CTX_get_options(new_ctx));
195.   
196.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;

ssl/ssl_lib.c:4553:1: start of procedure SSL_CTX_get_options()
  4551.    * control interface.
  4552.    */
  4553. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4554.   {
  4555.       return ctx->options;

ssl/ssl_lib.c:4555:5: 
  4553.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4554.   {
  4555. >     return ctx->options;
  4556.   }
  4557.   

ssl/ssl_lib.c:4556:1: return from a call to SSL_CTX_get_options
  4554.   {
  4555.       return ctx->options;
  4556. > }
  4557.   
  4558.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4568:1: start of procedure SSL_set_options()
  4566.   }
  4567.   
  4568. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4569.   {
  4570.       return s->options |= op;

ssl/ssl_lib.c:4570:5: 
  4568.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4569.   {
  4570. >     return s->options |= op;
  4571.   }
  4572.   

ssl/ssl_lib.c:4571:1: return from a call to SSL_set_options
  4569.   {
  4570.       return s->options |= op;
  4571. > }
  4572.   
  4573.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

test/handshake_helper.c:196:9: 
194.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
195.   
196. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
197.           return 1;
198.       } else if (len == strlen("server1") &&
