test/handshake_helper.c:203: error: NULL_DEREFERENCE
  pointer `ex_data` last assigned on line 151 could be null and is dereferenced at line 203, column 9.
Showing all 28 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:4045:1: start of procedure SSL_get_ex_data()
  4043.   }
  4044.   
  4045. > void *SSL_get_ex_data(const SSL *s, int idx)
  4046.   {
  4047.       return CRYPTO_get_ex_data(&s->ex_data, idx);

ssl/ssl_lib.c:4047:5: 
  4045.   void *SSL_get_ex_data(const SSL *s, int idx)
  4046.   {
  4047. >     return CRYPTO_get_ex_data(&s->ex_data, idx);
  4048.   }
  4049.   

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:4048:1: return from a call to SSL_get_ex_data
  4046.   {
  4047.       return CRYPTO_get_ex_data(&s->ex_data, idx);
  4048. > }
  4049.   
  4050.   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 false 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:198:16: Taking false branch
196.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
197.           return 1;
198.       } else if (len == strlen("server1") &&
                      ^
199.                  strncmp(servername, "server1", len) == 0) {
200.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;

test/handshake_helper.c:202:16: Taking true branch
200.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
201.           return 1;
202.       } else if (ignore) {
                      ^
203.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
204.           return 1;

test/handshake_helper.c:203:9: 
201.           return 1;
202.       } else if (ignore) {
203. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
204.           return 1;
205.       }
