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


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

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

ssl/ssl_lib.c:4014:1: start of procedure SSL_get_ex_data()
  4012.   }
  4013.   
  4014. > void *SSL_get_ex_data(const SSL *s, int idx)
  4015.   {
  4016.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:4016:5: 
  4014.   void *SSL_get_ex_data(const SSL *s, int idx)
  4015.   {
  4016. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  4017.   }
  4018.   

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:4017:1: return from a call to SSL_get_ex_data
  4015.   {
  4016.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  4017. > }
  4018.   
  4019.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

ssl/ssl_lib.c:3851:1: start of procedure SSL_set_SSL_CTX()
  3849.   }
  3850.   
  3851. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3852.   {
  3853.       CERT *new_cert;

ssl/ssl_lib.c:3854:9: Taking false branch
  3852.   {
  3853.       CERT *new_cert;
  3854.       if (ssl->ctx == ctx)
                  ^
  3855.           return ssl->ctx;
  3856.       if (ctx == NULL)

ssl/ssl_lib.c:3856:9: Taking false branch
  3854.       if (ssl->ctx == ctx)
  3855.           return ssl->ctx;
  3856.       if (ctx == NULL)
                  ^
  3857.           ctx = ssl->session_ctx;
  3858.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3858:5: Skipping ssl_cert_dup(): empty list of specs
  3856.       if (ctx == NULL)
  3857.           ctx = ssl->session_ctx;
  3858.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3859.       if (new_cert == NULL) {
  3860.           return NULL;

ssl/ssl_lib.c:3859:9: Taking false branch
  3857.           ctx = ssl->session_ctx;
  3858.       new_cert = ssl_cert_dup(ctx->cert);
  3859.       if (new_cert == NULL) {
                  ^
  3860.           return NULL;
  3861.       }

ssl/ssl_lib.c:3863:10: Taking false branch
  3861.       }
  3862.   
  3863.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  3864.           ssl_cert_free(new_cert);
  3865.           return NULL;

ssl/ssl_lib.c:3868:5: 
  3866.       }
  3867.   
  3868. >     ssl_cert_free(ssl->cert);
  3869.       ssl->cert = new_cert;
  3870.   

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:3869:5: 
  3867.   
  3868.       ssl_cert_free(ssl->cert);
  3869. >     ssl->cert = new_cert;
  3870.   
  3871.       /*

ssl/ssl_lib.c:3875:10: Condition is true
  3873.        * so setter APIs must prevent invalid lengths from entering the system.
  3874.        */
  3875.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3876.           return NULL;
  3877.   

ssl/ssl_lib.c:3875:10: Taking false branch
  3873.        * so setter APIs must prevent invalid lengths from entering the system.
  3874.        */
  3875.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3876.           return NULL;
  3877.   

ssl/ssl_lib.c:3884:10: Taking false branch
  3882.        * leave it unchanged.
  3883.        */
  3884.       if ((ssl->ctx != NULL) &&
                   ^
  3885.           (ssl->sid_ctx_length == ssl->ctx->sid_ctx_length) &&
  3886.           (memcmp(ssl->sid_ctx, ssl->ctx->sid_ctx, ssl->sid_ctx_length) == 0)) {

ssl/ssl_lib.c:3891:5: 
  3889.       }
  3890.   
  3891. >     SSL_CTX_up_ref(ctx);
  3892.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
  3893.       ssl->ctx = ctx;

ssl/ssl_lib.c:3005:1: start of procedure SSL_CTX_up_ref()
    3003.   }
    3004.   
    3005. > int SSL_CTX_up_ref(SSL_CTX *ctx)
    3006.   {
    3007.       int i;

ssl/ssl_lib.c:3009:9: 
    3007.       int i;
    3008.   
    3009. >     if (CRYPTO_UP_REF(&ctx->references, &i, ctx->lock) <= 0)
    3010.           return 0;
    3011.   

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:3009:9: Taking false branch
    3007.       int i;
    3008.   
    3009.       if (CRYPTO_UP_REF(&ctx->references, &i, ctx->lock) <= 0)
                    ^
    3010.           return 0;
    3011.   

ssl/ssl_lib.c:3014:14: Condition is false
    3012.       REF_PRINT_COUNT("SSL_CTX", ctx);
    3013.       REF_ASSERT_ISNT(i < 2);
    3014.       return ((i > 1) ? 1 : 0);
                         ^
    3015.   }
    3016.   

ssl/ssl_lib.c:3014:13: 
    3012.       REF_PRINT_COUNT("SSL_CTX", ctx);
    3013.       REF_ASSERT_ISNT(i < 2);
    3014. >     return ((i > 1) ? 1 : 0);
    3015.   }
    3016.   

ssl/ssl_lib.c:3014:5: 
    3012.       REF_PRINT_COUNT("SSL_CTX", ctx);
    3013.       REF_ASSERT_ISNT(i < 2);
    3014. >     return ((i > 1) ? 1 : 0);
    3015.   }
    3016.   

ssl/ssl_lib.c:3015:1: return from a call to SSL_CTX_up_ref
    3013.       REF_ASSERT_ISNT(i < 2);
    3014.       return ((i > 1) ? 1 : 0);
    3015. > }
    3016.   
    3017.   void SSL_CTX_free(SSL_CTX *a)

ssl/ssl_lib.c:3892:5: Skipping SSL_CTX_free(): empty list of specs
  3890.   
  3891.       SSL_CTX_up_ref(ctx);
  3892.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
              ^
  3893.       ssl->ctx = ctx;
  3894.   

ssl/ssl_lib.c:3893:5: 
  3891.       SSL_CTX_up_ref(ctx);
  3892.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
  3893. >     ssl->ctx = ctx;
  3894.   
  3895.       return ssl->ctx;

ssl/ssl_lib.c:3895:5: 
  3893.       ssl->ctx = ctx;
  3894.   
  3895. >     return ssl->ctx;
  3896.   }
  3897.   

ssl/ssl_lib.c:3896:1: return from a call to SSL_set_SSL_CTX
  3894.   
  3895.       return ssl->ctx;
  3896. > }
  3897.   
  3898.   int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)

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

ssl/ssl_lib.c:4438:1: start of procedure SSL_clear_options()
  4436.   }
  4437.   
  4438. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4439.   {
  4440.       return s->options &= ~op;

ssl/ssl_lib.c:4440:5: 
  4438.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4439.   {
  4440. >     return s->options &= ~op;
  4441.   }
  4442.   

ssl/ssl_lib.c:4441:1: return from a call to SSL_clear_options
  4439.   {
  4440.       return s->options &= ~op;
  4441. > }
  4442.   
  4443.   STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s)

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

ssl/ssl_lib.c:4413:1: start of procedure SSL_CTX_get_options()
  4411.    * control interface.
  4412.    */
  4413. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4414.   {
  4415.       return ctx->options;

ssl/ssl_lib.c:4415:5: 
  4413.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4414.   {
  4415. >     return ctx->options;
  4416.   }
  4417.   

ssl/ssl_lib.c:4416:1: return from a call to SSL_CTX_get_options
  4414.   {
  4415.       return ctx->options;
  4416. > }
  4417.   
  4418.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4428:1: start of procedure SSL_set_options()
  4426.   }
  4427.   
  4428. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4429.   {
  4430.       return s->options |= op;

ssl/ssl_lib.c:4430:5: 
  4428.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4429.   {
  4430. >     return s->options |= op;
  4431.   }
  4432.   

ssl/ssl_lib.c:4431:1: return from a call to SSL_set_options
  4429.   {
  4430.       return s->options |= op;
  4431. > }
  4432.   
  4433.   unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op)

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