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


test/handshake_helper.c:150:1: start of procedure client_hello_select_server_ctx()
148.   }
149.   
150. > static int client_hello_select_server_ctx(SSL *s, void *arg, int ignore)
151.   {
152.       const char *servername;

test/handshake_helper.c:155:5: 
153.       const unsigned char *p;
154.       size_t len, remaining;
155. >     HANDSHAKE_EX_DATA *ex_data =
156.           (HANDSHAKE_EX_DATA*)(SSL_get_ex_data(s, ex_data_idx));
157.   

ssl/ssl_lib.c:4205:1: start of procedure SSL_get_ex_data()
  4203.   }
  4204.   
  4205. > void *SSL_get_ex_data(const SSL *s, int idx)
  4206.   {
  4207.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:4207:5: 
  4205.   void *SSL_get_ex_data(const SSL *s, int idx)
  4206.   {
  4207. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  4208.   }
  4209.   

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:4208:1: return from a call to SSL_get_ex_data
  4206.   {
  4207.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  4208. > }
  4209.   
  4210.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

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

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

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

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

test/handshake_helper.c:169:9: Taking false branch
167.       len = (*(p++) << 8);
168.       len += *(p++);
169.       if (len + 2 != remaining)
               ^
170.           return 0;
171.       remaining = len;

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

test/handshake_helper.c:176:9: Taking false branch
174.        * the first one.
175.        */
176.       if (remaining == 0 || *p++ != TLSEXT_NAMETYPE_host_name)
               ^
177.           return 0;
178.       remaining--;

test/handshake_helper.c:176:27: Taking false branch
174.        * the first one.
175.        */
176.       if (remaining == 0 || *p++ != TLSEXT_NAMETYPE_host_name)
                                 ^
177.           return 0;
178.       remaining--;

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

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

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

test/handshake_helper.c:183:5: 
181.           return 0;
182.       len = (*(p++) << 8);
183. >     len += *(p++);
184.       if (len + 2 > remaining)
185.           return 0;

test/handshake_helper.c:184:9: Taking false branch
182.       len = (*(p++) << 8);
183.       len += *(p++);
184.       if (len + 2 > remaining)
               ^
185.           return 0;
186.       remaining = len;

test/handshake_helper.c:186:5: 
184.       if (len + 2 > remaining)
185.           return 0;
186. >     remaining = len;
187.       servername = (const char *)p;
188.   

test/handshake_helper.c:187:5: 
185.           return 0;
186.       remaining = len;
187. >     servername = (const char *)p;
188.   
189.       if (len == strlen("server2") && strncmp(servername, "server2", len) == 0) {

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

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

test/handshake_helper.c:190:9: 
188.   
189.       if (len == strlen("server2") && strncmp(servername, "server2", len) == 0) {
190. >         SSL_CTX *new_ctx = arg;
191.           SSL_set_SSL_CTX(s, new_ctx);
192.           /*

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

ssl/ssl_lib.c:4042:1: start of procedure SSL_set_SSL_CTX()
  4040.   }
  4041.   
  4042. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  4043.   {
  4044.       CERT *new_cert;

ssl/ssl_lib.c:4045:9: Taking false branch
  4043.   {
  4044.       CERT *new_cert;
  4045.       if (ssl->ctx == ctx)
                  ^
  4046.           return ssl->ctx;
  4047.       if (ctx == NULL)

ssl/ssl_lib.c:4047:9: Taking false branch
  4045.       if (ssl->ctx == ctx)
  4046.           return ssl->ctx;
  4047.       if (ctx == NULL)
                  ^
  4048.           ctx = ssl->session_ctx;
  4049.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:4049:5: Skipping ssl_cert_dup(): empty list of specs
  4047.       if (ctx == NULL)
  4048.           ctx = ssl->session_ctx;
  4049.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  4050.       if (new_cert == NULL) {
  4051.           return NULL;

ssl/ssl_lib.c:4050:9: Taking false branch
  4048.           ctx = ssl->session_ctx;
  4049.       new_cert = ssl_cert_dup(ctx->cert);
  4050.       if (new_cert == NULL) {
                  ^
  4051.           return NULL;
  4052.       }

ssl/ssl_lib.c:4054:10: Taking false branch
  4052.       }
  4053.   
  4054.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  4055.           ssl_cert_free(new_cert);
  4056.           return NULL;

ssl/ssl_lib.c:4059:5: 
  4057.       }
  4058.   
  4059. >     ssl_cert_free(ssl->cert);
  4060.       ssl->cert = new_cert;
  4061.   

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.       CRYPTO_DOWN_REF(&c->references, &i, c->lock);

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

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

ssl/ssl_lib.c:4060:5: 
  4058.   
  4059.       ssl_cert_free(ssl->cert);
  4060. >     ssl->cert = new_cert;
  4061.   
  4062.       /*

ssl/ssl_lib.c:4066:10: Condition is true
  4064.        * so setter APIs must prevent invalid lengths from entering the system.
  4065.        */
  4066.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  4067.           return NULL;
  4068.   

ssl/ssl_lib.c:4066:10: Taking false branch
  4064.        * so setter APIs must prevent invalid lengths from entering the system.
  4065.        */
  4066.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  4067.           return NULL;
  4068.   

ssl/ssl_lib.c:4075:10: Taking false branch
  4073.        * leave it unchanged.
  4074.        */
  4075.       if ((ssl->ctx != NULL) &&
                   ^
  4076.           (ssl->sid_ctx_length == ssl->ctx->sid_ctx_length) &&
  4077.           (memcmp(ssl->sid_ctx, ssl->ctx->sid_ctx, ssl->sid_ctx_length) == 0)) {

ssl/ssl_lib.c:4082:5: 
  4080.       }
  4081.   
  4082. >     SSL_CTX_up_ref(ctx);
  4083.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
  4084.       ssl->ctx = ctx;

ssl/ssl_lib.c:3139:1: start of procedure SSL_CTX_up_ref()
    3137.   }
    3138.   
    3139. > int SSL_CTX_up_ref(SSL_CTX *ctx)
    3140.   {
    3141.       int i;

ssl/ssl_lib.c:3143:9: 
    3141.       int i;
    3142.   
    3143. >     if (CRYPTO_UP_REF(&ctx->references, &i, ctx->lock) <= 0)
    3144.           return 0;
    3145.   

include/internal/refcount.h:32:1: start of procedure CRYPTO_UP_REF()
      30.   typedef _Atomic int CRYPTO_REF_COUNT;
      31.   
      32. > static 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 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.   /*

ssl/ssl_lib.c:3143:9: Taking false branch
    3141.       int i;
    3142.   
    3143.       if (CRYPTO_UP_REF(&ctx->references, &i, ctx->lock) <= 0)
                    ^
    3144.           return 0;
    3145.   

ssl/ssl_lib.c:3148:14: Condition is false
    3146.       REF_PRINT_COUNT("SSL_CTX", ctx);
    3147.       REF_ASSERT_ISNT(i < 2);
    3148.       return ((i > 1) ? 1 : 0);
                         ^
    3149.   }
    3150.   

ssl/ssl_lib.c:3148:13: 
    3146.       REF_PRINT_COUNT("SSL_CTX", ctx);
    3147.       REF_ASSERT_ISNT(i < 2);
    3148. >     return ((i > 1) ? 1 : 0);
    3149.   }
    3150.   

ssl/ssl_lib.c:3148:5: 
    3146.       REF_PRINT_COUNT("SSL_CTX", ctx);
    3147.       REF_ASSERT_ISNT(i < 2);
    3148. >     return ((i > 1) ? 1 : 0);
    3149.   }
    3150.   

ssl/ssl_lib.c:3149:1: return from a call to SSL_CTX_up_ref
    3147.       REF_ASSERT_ISNT(i < 2);
    3148.       return ((i > 1) ? 1 : 0);
    3149. > }
    3150.   
    3151.   void SSL_CTX_free(SSL_CTX *a)

ssl/ssl_lib.c:4083:5: Skipping SSL_CTX_free(): empty list of specs
  4081.   
  4082.       SSL_CTX_up_ref(ctx);
  4083.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
              ^
  4084.       ssl->ctx = ctx;
  4085.   

ssl/ssl_lib.c:4084:5: 
  4082.       SSL_CTX_up_ref(ctx);
  4083.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
  4084. >     ssl->ctx = ctx;
  4085.   
  4086.       return ssl->ctx;

ssl/ssl_lib.c:4086:5: 
  4084.       ssl->ctx = ctx;
  4085.   
  4086. >     return ssl->ctx;
  4087.   }
  4088.   

ssl/ssl_lib.c:4087:1: return from a call to SSL_set_SSL_CTX
  4085.   
  4086.       return ssl->ctx;
  4087. > }
  4088.   
  4089.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

test/handshake_helper.c:197:9: 
195.            * contexts differ/conflict
196.            */
197. >         SSL_clear_options(s, 0xFFFFFFFFL);
198.           SSL_set_options(s, SSL_CTX_get_options(new_ctx));
199.   

ssl/ssl_lib.c:4653:1: start of procedure SSL_clear_options()
  4651.   }
  4652.   
  4653. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4654.   {
  4655.       return s->options &= ~op;

ssl/ssl_lib.c:4655:5: 
  4653.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4654.   {
  4655. >     return s->options &= ~op;
  4656.   }
  4657.   

ssl/ssl_lib.c:4656:1: return from a call to SSL_clear_options
  4654.   {
  4655.       return s->options &= ~op;
  4656. > }
  4657.   
  4658.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

test/handshake_helper.c:198:9: 
196.            */
197.           SSL_clear_options(s, 0xFFFFFFFFL);
198. >         SSL_set_options(s, SSL_CTX_get_options(new_ctx));
199.   
200.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;

ssl/ssl_lib.c:4628:1: start of procedure SSL_CTX_get_options()
  4626.    * control interface.
  4627.    */
  4628. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4629.   {
  4630.       return ctx->options;

ssl/ssl_lib.c:4630:5: 
  4628.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4629.   {
  4630. >     return ctx->options;
  4631.   }
  4632.   

ssl/ssl_lib.c:4631:1: return from a call to SSL_CTX_get_options
  4629.   {
  4630.       return ctx->options;
  4631. > }
  4632.   
  4633.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4643:1: start of procedure SSL_set_options()
  4641.   }
  4642.   
  4643. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4644.   {
  4645.       return s->options |= op;

ssl/ssl_lib.c:4645:5: 
  4643.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4644.   {
  4645. >     return s->options |= op;
  4646.   }
  4647.   

ssl/ssl_lib.c:4646:1: return from a call to SSL_set_options
  4644.   {
  4645.       return s->options |= op;
  4646. > }
  4647.   
  4648.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

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