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


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

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

ssl/ssl_lib.c:3745:1: start of procedure SSL_get_ex_data()
  3743.   }
  3744.   
  3745. > void *SSL_get_ex_data(const SSL *s, int idx)
  3746.   {
  3747.       return (CRYPTO_get_ex_data(&s->ex_data, idx));

ssl/ssl_lib.c:3747:5: 
  3745.   void *SSL_get_ex_data(const SSL *s, int idx)
  3746.   {
  3747. >     return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3748.   }
  3749.   

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:3748:1: return from a call to SSL_get_ex_data
  3746.   {
  3747.       return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3748. > }
  3749.   
  3750.   int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg)

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

test/handshake_helper.c:156:9: Taking false branch
154.        */
155.       if (!SSL_early_get0_ext(s, TLSEXT_TYPE_server_name, &p, &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++) << 1);
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++) << 1);
160. >     len += *(p++);
161.       if (len + 2 != remaining)
162.           return 0;

test/handshake_helper.c:161:9: Taking false branch
159.       len = (*(p++) << 1);
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++) << 1);

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

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

test/handshake_helper.c:176:9: Taking false branch
174.       len = (*(p++) << 1);
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:3582:1: start of procedure SSL_set_SSL_CTX()
  3580.   }
  3581.   
  3582. > SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx)
  3583.   {
  3584.       CERT *new_cert;

ssl/ssl_lib.c:3585:9: Taking false branch
  3583.   {
  3584.       CERT *new_cert;
  3585.       if (ssl->ctx == ctx)
                  ^
  3586.           return ssl->ctx;
  3587.       if (ctx == NULL)

ssl/ssl_lib.c:3587:9: Taking false branch
  3585.       if (ssl->ctx == ctx)
  3586.           return ssl->ctx;
  3587.       if (ctx == NULL)
                  ^
  3588.           ctx = ssl->session_ctx;
  3589.       new_cert = ssl_cert_dup(ctx->cert);

ssl/ssl_lib.c:3589:5: Skipping ssl_cert_dup(): empty list of specs
  3587.       if (ctx == NULL)
  3588.           ctx = ssl->session_ctx;
  3589.       new_cert = ssl_cert_dup(ctx->cert);
              ^
  3590.       if (new_cert == NULL) {
  3591.           return NULL;

ssl/ssl_lib.c:3590:9: Taking false branch
  3588.           ctx = ssl->session_ctx;
  3589.       new_cert = ssl_cert_dup(ctx->cert);
  3590.       if (new_cert == NULL) {
                  ^
  3591.           return NULL;
  3592.       }

ssl/ssl_lib.c:3594:10: Taking false branch
  3592.       }
  3593.   
  3594.       if (!custom_exts_copy_flags(&new_cert->custext, &ssl->cert->custext)) {
                   ^
  3595.           ssl_cert_free(new_cert);
  3596.           return NULL;

ssl/ssl_lib.c:3599:5: 
  3597.       }
  3598.   
  3599. >     ssl_cert_free(ssl->cert);
  3600.       ssl->cert = new_cert;
  3601.   

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

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

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

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

ssl/ssl_lib.c:3600:5: 
  3598.   
  3599.       ssl_cert_free(ssl->cert);
  3600. >     ssl->cert = new_cert;
  3601.   
  3602.       /*

ssl/ssl_lib.c:3606:10: Condition is true
  3604.        * so setter APIs must prevent invalid lengths from entering the system.
  3605.        */
  3606.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3607.           return NULL;
  3608.   

ssl/ssl_lib.c:3606:10: Taking false branch
  3604.        * so setter APIs must prevent invalid lengths from entering the system.
  3605.        */
  3606.       if (!ossl_assert(ssl->sid_ctx_length <= sizeof(ssl->sid_ctx)))
                   ^
  3607.           return NULL;
  3608.   

ssl/ssl_lib.c:3615:10: Taking false branch
  3613.        * leave it unchanged.
  3614.        */
  3615.       if ((ssl->ctx != NULL) &&
                   ^
  3616.           (ssl->sid_ctx_length == ssl->ctx->sid_ctx_length) &&
  3617.           (memcmp(ssl->sid_ctx, ssl->ctx->sid_ctx, ssl->sid_ctx_length) == 0)) {

ssl/ssl_lib.c:3622:5: 
  3620.       }
  3621.   
  3622. >     SSL_CTX_up_ref(ctx);
  3623.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
  3624.       ssl->ctx = ctx;

ssl/ssl_lib.c:2757:1: start of procedure SSL_CTX_up_ref()
    2755.   }
    2756.   
    2757. > int SSL_CTX_up_ref(SSL_CTX *ctx)
    2758.   {
    2759.       int i;

ssl/ssl_lib.c:2761:9: 
    2759.       int i;
    2760.   
    2761. >     if (CRYPTO_UP_REF(&ctx->references, &i, ctx->lock) <= 0)
    2762.           return 0;
    2763.   

include/internal/refcount.h:25:1: start of procedure CRYPTO_UP_REF()
      23.   typedef _Atomic int CRYPTO_REF_COUNT;
      24.   
      25. > static ossl_inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, void *lock)
      26.   {
      27.       *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;

include/internal/refcount.h:27:5: 
      25.   static ossl_inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, void *lock)
      26.   {
      27. >     *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;
      28.       return 1;
      29.   }

include/internal/refcount.h:28:5: 
      26.   {
      27.       *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;
      28. >     return 1;
      29.   }
      30.   

include/internal/refcount.h:29:1: return from a call to CRYPTO_UP_REF
      27.       *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;
      28.       return 1;
      29. > }
      30.   
      31.   static ossl_inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, void *lock)

ssl/ssl_lib.c:2761:9: Taking false branch
    2759.       int i;
    2760.   
    2761.       if (CRYPTO_UP_REF(&ctx->references, &i, ctx->lock) <= 0)
                    ^
    2762.           return 0;
    2763.   

ssl/ssl_lib.c:2766:14: Condition is false
    2764.       REF_PRINT_COUNT("SSL_CTX", ctx);
    2765.       REF_ASSERT_ISNT(i < 2);
    2766.       return ((i > 1) ? 1 : 0);
                         ^
    2767.   }
    2768.   

ssl/ssl_lib.c:2766:13: 
    2764.       REF_PRINT_COUNT("SSL_CTX", ctx);
    2765.       REF_ASSERT_ISNT(i < 2);
    2766. >     return ((i > 1) ? 1 : 0);
    2767.   }
    2768.   

ssl/ssl_lib.c:2766:5: 
    2764.       REF_PRINT_COUNT("SSL_CTX", ctx);
    2765.       REF_ASSERT_ISNT(i < 2);
    2766. >     return ((i > 1) ? 1 : 0);
    2767.   }
    2768.   

ssl/ssl_lib.c:2767:1: return from a call to SSL_CTX_up_ref
    2765.       REF_ASSERT_ISNT(i < 2);
    2766.       return ((i > 1) ? 1 : 0);
    2767. > }
    2768.   
    2769.   void SSL_CTX_free(SSL_CTX *a)

ssl/ssl_lib.c:3623:5: Skipping SSL_CTX_free(): empty list of specs
  3621.   
  3622.       SSL_CTX_up_ref(ctx);
  3623.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
              ^
  3624.       ssl->ctx = ctx;
  3625.   

ssl/ssl_lib.c:3624:5: 
  3622.       SSL_CTX_up_ref(ctx);
  3623.       SSL_CTX_free(ssl->ctx);     /* decrement reference count */
  3624. >     ssl->ctx = ctx;
  3625.   
  3626.       return ssl->ctx;

ssl/ssl_lib.c:3626:5: 
  3624.       ssl->ctx = ctx;
  3625.   
  3626. >     return ssl->ctx;
  3627.   }
  3628.   

ssl/ssl_lib.c:3627:1: return from a call to SSL_set_SSL_CTX
  3625.   
  3626.       return ssl->ctx;
  3627. > }
  3628.   
  3629.   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:4163:1: start of procedure SSL_clear_options()
  4161.   }
  4162.   
  4163. > unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4164.   {
  4165.       return s->options &= ~op;

ssl/ssl_lib.c:4165:5: 
  4163.   unsigned long SSL_clear_options(SSL *s, unsigned long op)
  4164.   {
  4165. >     return s->options &= ~op;
  4166.   }
  4167.   

ssl/ssl_lib.c:4166:1: return from a call to SSL_clear_options
  4164.   {
  4165.       return s->options &= ~op;
  4166. > }
  4167.   
  4168.   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:4138:1: start of procedure SSL_CTX_get_options()
  4136.    * control interface.
  4137.    */
  4138. > unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4139.   {
  4140.       return ctx->options;

ssl/ssl_lib.c:4140:5: 
  4138.   unsigned long SSL_CTX_get_options(const SSL_CTX *ctx)
  4139.   {
  4140. >     return ctx->options;
  4141.   }
  4142.   

ssl/ssl_lib.c:4141:1: return from a call to SSL_CTX_get_options
  4139.   {
  4140.       return ctx->options;
  4141. > }
  4142.   
  4143.   unsigned long SSL_get_options(const SSL *s)

ssl/ssl_lib.c:4153:1: start of procedure SSL_set_options()
  4151.   }
  4152.   
  4153. > unsigned long SSL_set_options(SSL *s, unsigned long op)
  4154.   {
  4155.       return s->options |= op;

ssl/ssl_lib.c:4155:5: 
  4153.   unsigned long SSL_set_options(SSL *s, unsigned long op)
  4154.   {
  4155. >     return s->options |= op;
  4156.   }
  4157.   

ssl/ssl_lib.c:4156:1: return from a call to SSL_set_options
  4154.   {
  4155.       return s->options |= op;
  4156. > }
  4157.   
  4158.   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") &&
