crypto/x509/x509_vfy.c:1070: error: NULL_DEREFERENCE
  pointer `crl_issuer` last assigned on line 1069 could be null and is dereferenced by call to `X509_get_subject_name()` at line 1070, column 27.
Showing all 52 steps of the trace


crypto/x509/x509_vfy.c:1047:1: start of procedure crl_akid_check()
1045.   }
1046.   
1047. > static void crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl,
1048.                              X509 **pissuer, int *pcrl_score)
1049.   {

crypto/x509/x509_vfy.c:1050:5: 
1048.                              X509 **pissuer, int *pcrl_score)
1049.   {
1050. >     X509 *crl_issuer = NULL;
1051.       X509_NAME *cnm = X509_CRL_get_issuer(crl);
1052.       int cidx = ctx->error_depth;

crypto/x509/x509_vfy.c:1051:5: 
1049.   {
1050.       X509 *crl_issuer = NULL;
1051. >     X509_NAME *cnm = X509_CRL_get_issuer(crl);
1052.       int cidx = ctx->error_depth;
1053.       int i;

crypto/x509/x509cset.c:155:1: start of procedure X509_CRL_get_issuer()
  153.   }
  154.   
  155. > X509_NAME *X509_CRL_get_issuer(X509_CRL *crl)
  156.   {
  157.       return crl->crl.issuer;

crypto/x509/x509cset.c:157:5: 
  155.   X509_NAME *X509_CRL_get_issuer(X509_CRL *crl)
  156.   {
  157. >     return crl->crl.issuer;
  158.   }
  159.   

crypto/x509/x509cset.c:158:1: return from a call to X509_CRL_get_issuer
  156.   {
  157.       return crl->crl.issuer;
  158. > }
  159.   
  160.   STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(X509_CRL *crl)

crypto/x509/x509_vfy.c:1052:5: 
1050.       X509 *crl_issuer = NULL;
1051.       X509_NAME *cnm = X509_CRL_get_issuer(crl);
1052. >     int cidx = ctx->error_depth;
1053.       int i;
1054.   

crypto/x509/x509_vfy.c:1055:9: 
1053.       int i;
1054.   
1055. >     if (cidx != sk_X509_num(ctx->chain) - 1)
1056.           cidx++;
1057.   

include/openssl/x509.h:169:1: start of procedure sk_X509_num()
  167.   typedef struct x509_cinf_st X509_CINF;
  168.   
  169. > DEFINE_STACK_OF(X509)
  170.   
  171.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:316:1: start of procedure sk_num()
    314.   }
    315.   
    316. > int sk_num(const _STACK *st)
    317.   {
    318.       if (st == NULL)

crypto/stack/stack.c:318:9: Taking true branch
    316.   int sk_num(const _STACK *st)
    317.   {
    318.       if (st == NULL)
                   ^
    319.           return -1;
    320.       return st->num;

crypto/stack/stack.c:319:9: 
    317.   {
    318.       if (st == NULL)
    319. >         return -1;
    320.       return st->num;
    321.   }

crypto/stack/stack.c:321:1: return from a call to sk_num
    319.           return -1;
    320.       return st->num;
    321. > }
    322.   
    323.   void *sk_value(const _STACK *st, int i)

include/openssl/x509.h:169:1: return from a call to sk_X509_num
  167.   typedef struct x509_cinf_st X509_CINF;
  168.   
  169. > DEFINE_STACK_OF(X509)
  170.   
  171.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:1055:9: Taking true branch
1053.       int i;
1054.   
1055.       if (cidx != sk_X509_num(ctx->chain) - 1)
                ^
1056.           cidx++;
1057.   

crypto/x509/x509_vfy.c:1056:9: 
1054.   
1055.       if (cidx != sk_X509_num(ctx->chain) - 1)
1056. >         cidx++;
1057.   
1058.       crl_issuer = sk_X509_value(ctx->chain, cidx);

crypto/x509/x509_vfy.c:1058:5: 
1056.           cidx++;
1057.   
1058. >     crl_issuer = sk_X509_value(ctx->chain, cidx);
1059.   
1060.       if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {

include/openssl/x509.h:169:1: start of procedure sk_X509_value()
  167.   typedef struct x509_cinf_st X509_CINF;
  168.   
  169. > DEFINE_STACK_OF(X509)
  170.   
  171.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:323:1: start of procedure sk_value()
    321.   }
    322.   
    323. > void *sk_value(const _STACK *st, int i)
    324.   {
    325.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:325:10: Taking true branch
    323.   void *sk_value(const _STACK *st, int i)
    324.   {
    325.       if (!st || (i < 0) || (i >= st->num))
                    ^
    326.           return NULL;
    327.       return st->data[i];

crypto/stack/stack.c:326:9: 
    324.   {
    325.       if (!st || (i < 0) || (i >= st->num))
    326. >         return NULL;
    327.       return st->data[i];
    328.   }

crypto/stack/stack.c:328:1: return from a call to sk_value
    326.           return NULL;
    327.       return st->data[i];
    328. > }
    329.   
    330.   void *sk_set(_STACK *st, int i, void *value)

include/openssl/x509.h:169:1: return from a call to sk_X509_value
  167.   typedef struct x509_cinf_st X509_CINF;
  168.   
  169. > DEFINE_STACK_OF(X509)
  170.   
  171.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:1060:9: 
1058.       crl_issuer = sk_X509_value(ctx->chain, cidx);
1059.   
1060. >     if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {
1061.           if (*pcrl_score & CRL_SCORE_ISSUER_NAME) {
1062.               *pcrl_score |= CRL_SCORE_AKID | CRL_SCORE_ISSUER_CERT;

crypto/x509v3/v3_purp.c:812:1: start of procedure X509_check_akid()
  810.   }
  811.   
  812. > int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid)
  813.   {
  814.   

crypto/x509v3/v3_purp.c:815:10: Taking false branch
  813.   {
  814.   
  815.       if (!akid)
                  ^
  816.           return X509_V_OK;
  817.   

crypto/x509v3/v3_purp.c:819:9: Taking false branch
  817.   
  818.       /* Check key ids (if present) */
  819.       if (akid->keyid && issuer->skid &&
                 ^
  820.           ASN1_OCTET_STRING_cmp(akid->keyid, issuer->skid))
  821.           return X509_V_ERR_AKID_SKID_MISMATCH;

crypto/x509v3/v3_purp.c:823:9: Taking false branch
  821.           return X509_V_ERR_AKID_SKID_MISMATCH;
  822.       /* Check serial number */
  823.       if (akid->serial &&
                 ^
  824.           ASN1_INTEGER_cmp(X509_get_serialNumber(issuer), akid->serial))
  825.           return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;

crypto/x509v3/v3_purp.c:827:9: Taking false branch
  825.           return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
  826.       /* Check issuer name */
  827.       if (akid->issuer) {
                 ^
  828.           /*
  829.            * Ugh, for some peculiar reason AKID includes SEQUENCE OF

crypto/x509v3/v3_purp.c:848:5: 
  846.               return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
  847.       }
  848. >     return X509_V_OK;
  849.   }
  850.   

crypto/x509v3/v3_purp.c:849:1: return from a call to X509_check_akid
  847.       }
  848.       return X509_V_OK;
  849. > }
  850.   
  851.   uint32_t X509_get_extension_flags(X509 *x)

crypto/x509/x509_vfy.c:1060:9: Taking true branch
1058.       crl_issuer = sk_X509_value(ctx->chain, cidx);
1059.   
1060.       if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {
                ^
1061.           if (*pcrl_score & CRL_SCORE_ISSUER_NAME) {
1062.               *pcrl_score |= CRL_SCORE_AKID | CRL_SCORE_ISSUER_CERT;

crypto/x509/x509_vfy.c:1061:13: Taking false branch
1059.   
1060.       if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {
1061.           if (*pcrl_score & CRL_SCORE_ISSUER_NAME) {
                    ^
1062.               *pcrl_score |= CRL_SCORE_AKID | CRL_SCORE_ISSUER_CERT;
1063.               *pissuer = crl_issuer;

crypto/x509/x509_vfy.c:1068:10: 
1066.       }
1067.   
1068. >     for (cidx++; cidx < sk_X509_num(ctx->chain); cidx++) {
1069.           crl_issuer = sk_X509_value(ctx->chain, cidx);
1070.           if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))

crypto/x509/x509_vfy.c:1068:18: 
1066.       }
1067.   
1068. >     for (cidx++; cidx < sk_X509_num(ctx->chain); cidx++) {
1069.           crl_issuer = sk_X509_value(ctx->chain, cidx);
1070.           if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))

include/openssl/x509.h:169:1: start of procedure sk_X509_num()
  167.   typedef struct x509_cinf_st X509_CINF;
  168.   
  169. > DEFINE_STACK_OF(X509)
  170.   
  171.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:316:1: start of procedure sk_num()
    314.   }
    315.   
    316. > int sk_num(const _STACK *st)
    317.   {
    318.       if (st == NULL)

crypto/stack/stack.c:318:9: Taking true branch
    316.   int sk_num(const _STACK *st)
    317.   {
    318.       if (st == NULL)
                   ^
    319.           return -1;
    320.       return st->num;

crypto/stack/stack.c:319:9: 
    317.   {
    318.       if (st == NULL)
    319. >         return -1;
    320.       return st->num;
    321.   }

crypto/stack/stack.c:321:1: return from a call to sk_num
    319.           return -1;
    320.       return st->num;
    321. > }
    322.   
    323.   void *sk_value(const _STACK *st, int i)

include/openssl/x509.h:169:1: return from a call to sk_X509_num
  167.   typedef struct x509_cinf_st X509_CINF;
  168.   
  169. > DEFINE_STACK_OF(X509)
  170.   
  171.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:1068:18: Loop condition is true. Entering loop body
1066.       }
1067.   
1068.       for (cidx++; cidx < sk_X509_num(ctx->chain); cidx++) {
                         ^
1069.           crl_issuer = sk_X509_value(ctx->chain, cidx);
1070.           if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))

crypto/x509/x509_vfy.c:1069:9: 
1067.   
1068.       for (cidx++; cidx < sk_X509_num(ctx->chain); cidx++) {
1069. >         crl_issuer = sk_X509_value(ctx->chain, cidx);
1070.           if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))
1071.               continue;

include/openssl/x509.h:169:1: start of procedure sk_X509_value()
  167.   typedef struct x509_cinf_st X509_CINF;
  168.   
  169. > DEFINE_STACK_OF(X509)
  170.   
  171.   /* This is used for a table of trust checking functions */

crypto/stack/stack.c:323:1: start of procedure sk_value()
    321.   }
    322.   
    323. > void *sk_value(const _STACK *st, int i)
    324.   {
    325.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:325:10: Taking true branch
    323.   void *sk_value(const _STACK *st, int i)
    324.   {
    325.       if (!st || (i < 0) || (i >= st->num))
                    ^
    326.           return NULL;
    327.       return st->data[i];

crypto/stack/stack.c:326:9: 
    324.   {
    325.       if (!st || (i < 0) || (i >= st->num))
    326. >         return NULL;
    327.       return st->data[i];
    328.   }

crypto/stack/stack.c:328:1: return from a call to sk_value
    326.           return NULL;
    327.       return st->data[i];
    328. > }
    329.   
    330.   void *sk_set(_STACK *st, int i, void *value)

include/openssl/x509.h:169:1: return from a call to sk_X509_value
  167.   typedef struct x509_cinf_st X509_CINF;
  168.   
  169. > DEFINE_STACK_OF(X509)
  170.   
  171.   /* This is used for a table of trust checking functions */

crypto/x509/x509_vfy.c:1070:13: 
1068.       for (cidx++; cidx < sk_X509_num(ctx->chain); cidx++) {
1069.           crl_issuer = sk_X509_value(ctx->chain, cidx);
1070. >         if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))
1071.               continue;
1072.           if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {

crypto/x509/x509_cmp.c:148:1: start of procedure X509_get_subject_name()
  146.   #endif
  147.   
  148. > X509_NAME *X509_get_subject_name(X509 *a)
  149.   {
  150.       return (a->cert_info.subject);

crypto/x509/x509_cmp.c:150:5: 
  148.   X509_NAME *X509_get_subject_name(X509 *a)
  149.   {
  150. >     return (a->cert_info.subject);
  151.   }
  152.   

static void crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl,
                           X509 **pissuer, int *pcrl_score)
{
    X509 *crl_issuer = NULL;
    X509_NAME *cnm = X509_CRL_get_issuer(crl);
    int cidx = ctx->error_depth;
    int i;
    if (cidx != sk_X509_num(ctx->chain) - 1)
        cidx++;
    crl_issuer = sk_X509_value(ctx->chain, cidx);
    if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {
        if (*pcrl_score & CRL_SCORE_ISSUER_NAME) {
            *pcrl_score |= CRL_SCORE_AKID | CRL_SCORE_ISSUER_CERT;
            *pissuer = crl_issuer;
            return;
        }
    }
    for (cidx++; cidx < sk_X509_num(ctx->chain); cidx++) {
        crl_issuer = sk_X509_value(ctx->chain, cidx);
        if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))
            continue;
        if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {
            *pcrl_score |= CRL_SCORE_AKID | CRL_SCORE_SAME_PATH;
            *pissuer = crl_issuer;
            return;
        }
    }
    if (!(ctx->param->flags & X509_V_FLAG_EXTENDED_CRL_SUPPORT))
        return;
    for (i = 0; i < sk_X509_num(ctx->untrusted); i++) {
        crl_issuer = sk_X509_value(ctx->untrusted, i);
        if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))
            continue;
        if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {
            *pissuer = crl_issuer;
            *pcrl_score |= CRL_SCORE_AKID;
            return;
        }
    }
}
['static void crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl,\n                           X509 **pissuer, int *pcrl_score)\n{\n    X509 *crl_issuer = NULL;\n    X509_NAME *cnm = X509_CRL_get_issuer(crl);\n    int cidx = ctx->error_depth;\n    int i;\n    if (cidx != sk_X509_num(ctx->chain) - 1)\n        cidx++;\n    crl_issuer = sk_X509_value(ctx->chain, cidx);\n    if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {\n        if (*pcrl_score & CRL_SCORE_ISSUER_NAME) {\n            *pcrl_score |= CRL_SCORE_AKID | CRL_SCORE_ISSUER_CERT;\n            *pissuer = crl_issuer;\n            return;\n        }\n    }\n    for (cidx++; cidx < sk_X509_num(ctx->chain); cidx++) {\n        crl_issuer = sk_X509_value(ctx->chain, cidx);\n        if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))\n            continue;\n        if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {\n            *pcrl_score |= CRL_SCORE_AKID | CRL_SCORE_SAME_PATH;\n            *pissuer = crl_issuer;\n            return;\n        }\n    }\n    if (!(ctx->param->flags & X509_V_FLAG_EXTENDED_CRL_SUPPORT))\n        return;\n    for (i = 0; i < sk_X509_num(ctx->untrusted); i++) {\n        crl_issuer = sk_X509_value(ctx->untrusted, i);\n        if (X509_NAME_cmp(X509_get_subject_name(crl_issuer), cnm))\n            continue;\n        if (X509_check_akid(crl_issuer, crl->akid) == X509_V_OK) {\n            *pissuer = crl_issuer;\n            *pcrl_score |= CRL_SCORE_AKID;\n            return;\n        }\n    }\n}', 'X509_NAME *X509_CRL_get_issuer(X509_CRL *crl)\n{\n    return crl->crl.issuer;\n}', 'DEFINE_STACK_OF(X509)', 'int sk_num(const _STACK *st)\n{\n    if (st == NULL)\n        return -1;\n    return st->num;\n}', 'void *sk_value(const _STACK *st, int i)\n{\n    if (!st || (i < 0) || (i >= st->num))\n        return NULL;\n    return st->data[i];\n}', 'int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid)\n{\n    if (!akid)\n        return X509_V_OK;\n    if (akid->keyid && issuer->skid &&\n        ASN1_OCTET_STRING_cmp(akid->keyid, issuer->skid))\n        return X509_V_ERR_AKID_SKID_MISMATCH;\n    if (akid->serial &&\n        ASN1_INTEGER_cmp(X509_get_serialNumber(issuer), akid->serial))\n        return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;\n    if (akid->issuer) {\n        GENERAL_NAMES *gens;\n        GENERAL_NAME *gen;\n        X509_NAME *nm = NULL;\n        int i;\n        gens = akid->issuer;\n        for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) {\n            gen = sk_GENERAL_NAME_value(gens, i);\n            if (gen->type == GEN_DIRNAME) {\n                nm = gen->d.dirn;\n                break;\n            }\n        }\n        if (nm && X509_NAME_cmp(nm, X509_get_issuer_name(issuer)))\n            return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;\n    }\n    return X509_V_OK;\n}', 'X509_NAME *X509_get_subject_name(X509 *a)\n{\n    return (a->cert_info.subject);\n}']