ssl/statem/statem_clnt.c:1352: error: NULL_DEREFERENCE
  pointer `sk` last assigned on line 1351 could be null and is dereferenced by call to `sk_SSL_CIPHER_find()` at line 1352, column 9.
Showing all 25 steps of the trace


ssl/statem/statem_clnt.c:1328:1: start of procedure set_client_ciphersuite()
1326.   }
1327.   
1328. > static int set_client_ciphersuite(SSL *s, const unsigned char *cipherchars)
1329.   {
1330.       STACK_OF(SSL_CIPHER) *sk;

ssl/statem/statem_clnt.c:1334:5: 
1332.       int i;
1333.   
1334. >     c = ssl_get_cipher_by_char(s, cipherchars, 0);
1335.       if (c == NULL) {
1336.           /* unknown cipher */

ssl/ssl_ciph.c:2035:1: start of procedure ssl_get_cipher_by_char()
  2033.   }
  2034.   
  2035. > const SSL_CIPHER *ssl_get_cipher_by_char(SSL *ssl, const unsigned char *ptr,
  2036.                                            int all)
  2037.   {

ssl/ssl_ciph.c:2038:5: Skipping __function_pointer__(): unresolved function pointer
  2036.                                            int all)
  2037.   {
  2038.       const SSL_CIPHER *c = ssl->method->get_cipher_by_char(ptr);
              ^
  2039.   
  2040.       if (c == NULL || (!all && c->valid == 0))

ssl/ssl_ciph.c:2040:9: Taking false branch
  2038.       const SSL_CIPHER *c = ssl->method->get_cipher_by_char(ptr);
  2039.   
  2040.       if (c == NULL || (!all && c->valid == 0))
                  ^
  2041.           return NULL;
  2042.       return c;

ssl/ssl_ciph.c:2040:24: Taking true branch
  2038.       const SSL_CIPHER *c = ssl->method->get_cipher_by_char(ptr);
  2039.   
  2040.       if (c == NULL || (!all && c->valid == 0))
                                 ^
  2041.           return NULL;
  2042.       return c;

ssl/ssl_ciph.c:2040:31: Taking false branch
  2038.       const SSL_CIPHER *c = ssl->method->get_cipher_by_char(ptr);
  2039.   
  2040.       if (c == NULL || (!all && c->valid == 0))
                                        ^
  2041.           return NULL;
  2042.       return c;

ssl/ssl_ciph.c:2042:5: 
  2040.       if (c == NULL || (!all && c->valid == 0))
  2041.           return NULL;
  2042. >     return c;
  2043.   }
  2044.   

ssl/ssl_ciph.c:2043:1: return from a call to ssl_get_cipher_by_char
  2041.           return NULL;
  2042.       return c;
  2043. > }
  2044.   
  2045.   const SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr)

ssl/statem/statem_clnt.c:1335:9: Taking false branch
1333.   
1334.       c = ssl_get_cipher_by_char(s, cipherchars, 0);
1335.       if (c == NULL) {
                ^
1336.           /* unknown cipher */
1337.           SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SET_CLIENT_CIPHERSUITE,

ssl/statem/statem_clnt.c:1345:9: Taking false branch
1343.        * or it's not allowed for the selected protocol. So we return an error.
1344.        */
1345.       if (ssl_cipher_disabled(s, c, SSL_SECOP_CIPHER_CHECK, 1)) {
                ^
1346.           SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SET_CLIENT_CIPHERSUITE,
1347.                    SSL_R_WRONG_CIPHER_RETURNED);

ssl/statem/statem_clnt.c:1351:5: 
1349.       }
1350.   
1351. >     sk = ssl_get_ciphers_by_id(s);
1352.       i = sk_SSL_CIPHER_find(sk, c);
1353.       if (i < 0) {

ssl/ssl_lib.c:2481:1: start of procedure ssl_get_ciphers_by_id()
  2479.   /** return a STACK of the ciphers available for the SSL and in order of
  2480.    * algorithm id */
  2481. > STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s)
  2482.   {
  2483.       if (s != NULL) {

ssl/ssl_lib.c:2483:9: Taking true branch
  2481.   STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s)
  2482.   {
  2483.       if (s != NULL) {
                  ^
  2484.           if (s->cipher_list_by_id != NULL) {
  2485.               return s->cipher_list_by_id;

ssl/ssl_lib.c:2484:13: Taking false branch
  2482.   {
  2483.       if (s != NULL) {
  2484.           if (s->cipher_list_by_id != NULL) {
                      ^
  2485.               return s->cipher_list_by_id;
  2486.           } else if ((s->ctx != NULL) && (s->ctx->cipher_list_by_id != NULL)) {

ssl/ssl_lib.c:2486:21: Taking true branch
  2484.           if (s->cipher_list_by_id != NULL) {
  2485.               return s->cipher_list_by_id;
  2486.           } else if ((s->ctx != NULL) && (s->ctx->cipher_list_by_id != NULL)) {
                              ^
  2487.               return s->ctx->cipher_list_by_id;
  2488.           }

ssl/ssl_lib.c:2486:41: Taking false branch
  2484.           if (s->cipher_list_by_id != NULL) {
  2485.               return s->cipher_list_by_id;
  2486.           } else if ((s->ctx != NULL) && (s->ctx->cipher_list_by_id != NULL)) {
                                                  ^
  2487.               return s->ctx->cipher_list_by_id;
  2488.           }

ssl/ssl_lib.c:2490:5: 
  2488.           }
  2489.       }
  2490. >     return NULL;
  2491.   }
  2492.   

ssl/ssl_lib.c:2491:1: return from a call to ssl_get_ciphers_by_id
  2489.       }
  2490.       return NULL;
  2491. > }
  2492.   
  2493.   /** The old interface to get the same thing as SSL_get_ciphers() */

ssl/statem/statem_clnt.c:1352:5: 
1350.   
1351.       sk = ssl_get_ciphers_by_id(s);
1352. >     i = sk_SSL_CIPHER_find(sk, c);
1353.       if (i < 0) {
1354.           /* we did not say we would use this cipher */

include/openssl/ssl.h:945:1: start of procedure sk_SSL_CIPHER_find()
  943.    * in VisualStudio 2015
  944.    */
  945. > DEFINE_STACK_OF_CONST(SSL_CIPHER)
  946.   DEFINE_STACK_OF(SSL_COMP)
  947.   

crypto/stack/stack.c:313:1: start of procedure OPENSSL_sk_find()
    311.   }
    312.   
    313. > int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)
    314.   {
    315.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);

crypto/stack/stack.c:315:5: 
    313.   int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)
    314.   {
    315. >     return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
    316.   }
    317.   

crypto/stack/stack.c:284:1: start of procedure internal_find()
      282.   }
      283.   
      284. > static int internal_find(OPENSSL_STACK *st, const void *data,
      285.                            int ret_val_options)
      286.   {

crypto/stack/stack.c:290:9: 
      288.       int i;
      289.   
      290. >     if (st->num == 0)
      291.           return -1;
      292.   

static int set_client_ciphersuite(SSL *s, const unsigned char *cipherchars)
{
    STACK_OF(SSL_CIPHER) *sk;
    const SSL_CIPHER *c;
    int i;
    c = ssl_get_cipher_by_char(s, cipherchars, 0);
    if (c == NULL) {
        SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SET_CLIENT_CIPHERSUITE,
                 SSL_R_UNKNOWN_CIPHER_RETURNED);
        return 0;
    }
    if (ssl_cipher_disabled(s, c, SSL_SECOP_CIPHER_CHECK, 1)) {
        SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SET_CLIENT_CIPHERSUITE,
                 SSL_R_WRONG_CIPHER_RETURNED);
        return 0;
    }
    sk = ssl_get_ciphers_by_id(s);
    i = sk_SSL_CIPHER_find(sk, c);
    if (i < 0) {
        SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SET_CLIENT_CIPHERSUITE,
                 SSL_R_WRONG_CIPHER_RETURNED);
        return 0;
    }
    if (SSL_IS_TLS13(s) && s->s3->tmp.new_cipher != NULL
            && s->s3->tmp.new_cipher->id != c->id) {
        SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SET_CLIENT_CIPHERSUITE,
                 SSL_R_WRONG_CIPHER_RETURNED);
        return 0;
    }
    if (s->session->cipher != NULL)
        s->session->cipher_id = s->session->cipher->id;
    if (s->hit && (s->session->cipher_id != c->id)) {
        if (SSL_IS_TLS13(s)) {
            if (ssl_md(c->algorithm2)
                    != ssl_md(s->session->cipher->algorithm2)) {
                SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER,
                         SSL_F_SET_CLIENT_CIPHERSUITE,
                         SSL_R_CIPHERSUITE_DIGEST_HAS_CHANGED);
                return 0;
            }
        } else {
            SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SET_CLIENT_CIPHERSUITE,
                     SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED);
            return 0;
        }
    }
    s->s3->tmp.new_cipher = c;
    return 1;
}
['static int set_client_ciphersuite(SSL *s, const unsigned char *cipherchars)\n{\n    STACK_OF(SSL_CIPHER) *sk;\n    const SSL_CIPHER *c;\n    int i;\n    c = ssl_get_cipher_by_char(s, cipherchars, 0);\n    if (c == NULL) {\n        SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SET_CLIENT_CIPHERSUITE,\n                 SSL_R_UNKNOWN_CIPHER_RETURNED);\n        return 0;\n    }\n    if (ssl_cipher_disabled(s, c, SSL_SECOP_CIPHER_CHECK, 1)) {\n        SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SET_CLIENT_CIPHERSUITE,\n                 SSL_R_WRONG_CIPHER_RETURNED);\n        return 0;\n    }\n    sk = ssl_get_ciphers_by_id(s);\n    i = sk_SSL_CIPHER_find(sk, c);\n    if (i < 0) {\n        SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SET_CLIENT_CIPHERSUITE,\n                 SSL_R_WRONG_CIPHER_RETURNED);\n        return 0;\n    }\n    if (SSL_IS_TLS13(s) && s->s3->tmp.new_cipher != NULL\n            && s->s3->tmp.new_cipher->id != c->id) {\n        SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SET_CLIENT_CIPHERSUITE,\n                 SSL_R_WRONG_CIPHER_RETURNED);\n        return 0;\n    }\n    if (s->session->cipher != NULL)\n        s->session->cipher_id = s->session->cipher->id;\n    if (s->hit && (s->session->cipher_id != c->id)) {\n        if (SSL_IS_TLS13(s)) {\n            if (ssl_md(c->algorithm2)\n                    != ssl_md(s->session->cipher->algorithm2)) {\n                SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER,\n                         SSL_F_SET_CLIENT_CIPHERSUITE,\n                         SSL_R_CIPHERSUITE_DIGEST_HAS_CHANGED);\n                return 0;\n            }\n        } else {\n            SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_SET_CLIENT_CIPHERSUITE,\n                     SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED);\n            return 0;\n        }\n    }\n    s->s3->tmp.new_cipher = c;\n    return 1;\n}', 'const SSL_CIPHER *ssl_get_cipher_by_char(SSL *ssl, const unsigned char *ptr,\n                                         int all)\n{\n    const SSL_CIPHER *c = ssl->method->get_cipher_by_char(ptr);\n    if (c == NULL || (!all && c->valid == 0))\n        return NULL;\n    return c;\n}', 'STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s)\n{\n    if (s != NULL) {\n        if (s->cipher_list_by_id != NULL) {\n            return s->cipher_list_by_id;\n        } else if ((s->ctx != NULL) && (s->ctx->cipher_list_by_id != NULL)) {\n            return s->ctx->cipher_list_by_id;\n        }\n    }\n    return NULL;\n}', 'int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)\n{\n    return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);\n}', 'static int internal_find(OPENSSL_STACK *st, const void *data,\n                         int ret_val_options)\n{\n    const void *r;\n    int i;\n    if (st->num == 0)\n        return -1;\n    if (st->comp == NULL) {\n        for (i = 0; i < st->num; i++)\n            if (st->data[i] == data)\n                return i;\n        return -1;\n    }\n    if (!st->sorted) {\n        if (st->num > 1)\n            qsort(st->data, st->num, sizeof(void *), st->comp);\n        st->sorted = 1;\n    }\n    if (data == NULL)\n        return -1;\n    r = OBJ_bsearch_ex_(&data, st->data, st->num, sizeof(void *), st->comp,\n                        ret_val_options);\n    return r == NULL ? -1 : (int)((const void **)r - st->data);\n}']