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


test/handshake_helper.c:142:1: start of procedure early_select_server_ctx()
140.   }
141.   
142. > static int early_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:3729:1: start of procedure SSL_get_ex_data()
  3727.   }
  3728.   
  3729. > void *SSL_get_ex_data(const SSL *s, int idx)
  3730.   {
  3731.       return (CRYPTO_get_ex_data(&s->ex_data, idx));

ssl/ssl_lib.c:3731:5: 
  3729.   void *SSL_get_ex_data(const SSL *s, int idx)
  3730.   {
  3731. >     return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3732.   }
  3733.   

crypto/ex_data.c:387:1: start of procedure CRYPTO_get_ex_data()
    385.    * particular index in the class used by this variable
    386.    */
    387. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    388.   {
    389.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))

crypto/ex_data.c:389:9: Taking true branch
    387.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    388.   {
    389.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
                   ^
    390.           return NULL;
    391.       return sk_void_value(ad->sk, idx);

crypto/ex_data.c:390:9: 
    388.   {
    389.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
    390. >         return NULL;
    391.       return sk_void_value(ad->sk, idx);
    392.   }

crypto/ex_data.c:392:1: return from a call to CRYPTO_get_ex_data
    390.           return NULL;
    391.       return sk_void_value(ad->sk, idx);
    392. > }

ssl/ssl_lib.c:3732:1: return from a call to SSL_get_ex_data
  3730.   {
  3731.       return (CRYPTO_get_ex_data(&s->ex_data, idx));
  3732. > }
  3733.   
  3734.   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_early_get0_ext(s, TLSEXT_TYPE_server_name, &p, &remaining) ||
                ^
155.           remaining <= 2)
156.           return 0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

test/handshake_helper.c:193:16: Taking false branch
191.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER2;
192.           return 1;
193.       } else if (len == strlen("server1") &&
                      ^
194.                  strncmp(servername, "server1", len) == 0) {
195.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;

test/handshake_helper.c:197:16: Taking true branch
195.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
196.           return 1;
197.       } else if (ignore) {
                      ^
198.           ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
199.           return 1;

test/handshake_helper.c:198:9: 
196.           return 1;
197.       } else if (ignore) {
198. >         ex_data->servername = SSL_TEST_SERVERNAME_SERVER1;
199.           return 1;
200.       }
