test/handshake_helper.c:207: error: NULL_DEREFERENCE
  pointer `ex_data` last assigned on line 155 could be null and is dereferenced at line 207, column 9.
Showing all 28 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 false 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:202:16: Taking false branch
200.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
201.           return 1;
202.       } else if (len == strlen("server1") &&
                      ^
203.                  strncmp(servername, "server1", len) == 0) {
204.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;

test/handshake_helper.c:206:16: Taking true branch
204.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
205.           return 1;
206.       } else if (ignore) {
                      ^
207.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
208.           return 1;

test/handshake_helper.c:207:9: 
205.           return 1;
206.       } else if (ignore) {
207. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
208.           return 1;
209.       }
