crypto/ts/ts_rsp_verify.c:457: error: NULL_DEREFERENCE
  pointer `signer` last assigned on line 413 could be null and is dereferenced by call to `ts_check_signer_name()` at line 457, column 25.
Showing all 36 steps of the trace


crypto/ts/ts_rsp_verify.c:410:1: start of procedure int_ts_RESP_verify_token()
408.    *      - Check if the TSA name is the expected TSA.
409.    */
410. > static int int_ts_RESP_verify_token(TS_VERIFY_CTX *ctx,
411.                                       PKCS7 *token, TS_TST_INFO *tst_info)
412.   {

crypto/ts/ts_rsp_verify.c:413:5: 
411.                                       PKCS7 *token, TS_TST_INFO *tst_info)
412.   {
413. >     X509 *signer = NULL;
414.       GENERAL_NAME *tsa_name = TS_TST_INFO_get_tsa(tst_info);
415.       X509_ALGOR *md_alg = NULL;

crypto/ts/ts_rsp_verify.c:414:5: 
412.   {
413.       X509 *signer = NULL;
414. >     GENERAL_NAME *tsa_name = TS_TST_INFO_get_tsa(tst_info);
415.       X509_ALGOR *md_alg = NULL;
416.       unsigned char *imprint = NULL;

crypto/ts/ts_rsp_utils.c:340:1: start of procedure TS_TST_INFO_get_tsa()
  338.   }
  339.   
  340. > GENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a)
  341.   {
  342.       return a->tsa;

crypto/ts/ts_rsp_utils.c:342:5: 
  340.   GENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a)
  341.   {
  342. >     return a->tsa;
  343.   }
  344.   

crypto/ts/ts_rsp_utils.c:343:1: return from a call to TS_TST_INFO_get_tsa
  341.   {
  342.       return a->tsa;
  343. > }
  344.   
  345.   STACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a)

crypto/ts/ts_rsp_verify.c:415:5: 
413.       X509 *signer = NULL;
414.       GENERAL_NAME *tsa_name = TS_TST_INFO_get_tsa(tst_info);
415. >     X509_ALGOR *md_alg = NULL;
416.       unsigned char *imprint = NULL;
417.       unsigned imprint_len = 0;

crypto/ts/ts_rsp_verify.c:416:5: 
414.       GENERAL_NAME *tsa_name = TS_TST_INFO_get_tsa(tst_info);
415.       X509_ALGOR *md_alg = NULL;
416. >     unsigned char *imprint = NULL;
417.       unsigned imprint_len = 0;
418.       int ret = 0;

crypto/ts/ts_rsp_verify.c:417:5: 
415.       X509_ALGOR *md_alg = NULL;
416.       unsigned char *imprint = NULL;
417. >     unsigned imprint_len = 0;
418.       int ret = 0;
419.   

crypto/ts/ts_rsp_verify.c:418:5: 
416.       unsigned char *imprint = NULL;
417.       unsigned imprint_len = 0;
418. >     int ret = 0;
419.   
420.       /* Verify the signature. */

crypto/ts/ts_rsp_verify.c:421:10: Taking false branch
419.   
420.       /* Verify the signature. */
421.       if ((ctx->flags & TS_VFY_SIGNATURE)
                ^
422.           && !TS_RESP_verify_signature(token, ctx->certs, ctx->store, &signer))
423.           goto err;

crypto/ts/ts_rsp_verify.c:426:10: Taking false branch
424.   
425.       /* Check version number of response. */
426.       if ((ctx->flags & TS_VFY_VERSION)
                ^
427.           && TS_TST_INFO_get_version(tst_info) != 1) {
428.           TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_UNSUPPORTED_VERSION);

crypto/ts/ts_rsp_verify.c:433:10: Taking true branch
431.   
432.       /* Check policies. */
433.       if ((ctx->flags & TS_VFY_POLICY)
                ^
434.           && !ts_check_policy(ctx->policy, tst_info))
435.           goto err;

crypto/ts/ts_rsp_verify.c:434:13: 
432.       /* Check policies. */
433.       if ((ctx->flags & TS_VFY_POLICY)
434. >         && !ts_check_policy(ctx->policy, tst_info))
435.           goto err;
436.   

crypto/ts/ts_rsp_verify.c:563:1: start of procedure ts_check_policy()
  561.   }
  562.   
  563. > static int ts_check_policy(ASN1_OBJECT *req_oid, TS_TST_INFO *tst_info)
  564.   {
  565.       ASN1_OBJECT *resp_oid = TS_TST_INFO_get_policy_id(tst_info);

crypto/ts/ts_rsp_verify.c:565:5: 
  563.   static int ts_check_policy(ASN1_OBJECT *req_oid, TS_TST_INFO *tst_info)
  564.   {
  565. >     ASN1_OBJECT *resp_oid = TS_TST_INFO_get_policy_id(tst_info);
  566.   
  567.       if (OBJ_cmp(req_oid, resp_oid) != 0) {

crypto/ts/ts_rsp_utils.c:136:1: start of procedure TS_TST_INFO_get_policy_id()
    134.   }
    135.   
    136. > ASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a)
    137.   {
    138.       return a->policy_id;

crypto/ts/ts_rsp_utils.c:138:5: 
    136.   ASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a)
    137.   {
    138. >     return a->policy_id;
    139.   }
    140.   

crypto/ts/ts_rsp_utils.c:139:1: return from a call to TS_TST_INFO_get_policy_id
    137.   {
    138.       return a->policy_id;
    139. > }
    140.   
    141.   int TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint)

crypto/ts/ts_rsp_verify.c:567:9: 
  565.       ASN1_OBJECT *resp_oid = TS_TST_INFO_get_policy_id(tst_info);
  566.   
  567. >     if (OBJ_cmp(req_oid, resp_oid) != 0) {
  568.           TSerr(TS_F_TS_CHECK_POLICY, TS_R_POLICY_MISMATCH);
  569.           return 0;

crypto/objects/obj_lib.c:124:1: start of procedure OBJ_cmp()
    122.   }
    123.   
    124. > int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b)
    125.   {
    126.       int ret;

crypto/objects/obj_lib.c:128:5: 
    126.       int ret;
    127.   
    128. >     ret = (a->length - b->length);
    129.       if (ret)
    130.           return (ret);

crypto/objects/obj_lib.c:129:9: Taking true branch
    127.   
    128.       ret = (a->length - b->length);
    129.       if (ret)
                   ^
    130.           return (ret);
    131.       return (memcmp(a->data, b->data, a->length));

crypto/objects/obj_lib.c:130:9: 
    128.       ret = (a->length - b->length);
    129.       if (ret)
    130. >         return (ret);
    131.       return (memcmp(a->data, b->data, a->length));
    132.   }

crypto/objects/obj_lib.c:132:1: return from a call to OBJ_cmp
    130.           return (ret);
    131.       return (memcmp(a->data, b->data, a->length));
    132. > }

crypto/ts/ts_rsp_verify.c:567:9: Taking false branch
  565.       ASN1_OBJECT *resp_oid = TS_TST_INFO_get_policy_id(tst_info);
  566.   
  567.       if (OBJ_cmp(req_oid, resp_oid) != 0) {
                 ^
  568.           TSerr(TS_F_TS_CHECK_POLICY, TS_R_POLICY_MISMATCH);
  569.           return 0;

crypto/ts/ts_rsp_verify.c:572:5: 
  570.       }
  571.   
  572. >     return 1;
  573.   }
  574.   

crypto/ts/ts_rsp_verify.c:573:1: return from a call to ts_check_policy
  571.   
  572.       return 1;
  573. > }
  574.   
  575.   static int ts_compute_imprint(BIO *data, TS_TST_INFO *tst_info,

crypto/ts/ts_rsp_verify.c:434:13: Taking false branch
432.       /* Check policies. */
433.       if ((ctx->flags & TS_VFY_POLICY)
434.           && !ts_check_policy(ctx->policy, tst_info))
                   ^
435.           goto err;
436.   

crypto/ts/ts_rsp_verify.c:438:10: Taking true branch
436.   
437.       /* Check message imprints. */
438.       if ((ctx->flags & TS_VFY_IMPRINT)
                ^
439.           && !ts_check_imprints(ctx->md_alg, ctx->imprint, ctx->imprint_len,
440.                                 tst_info))

crypto/ts/ts_rsp_verify.c:439:13: Taking false branch
437.       /* Check message imprints. */
438.       if ((ctx->flags & TS_VFY_IMPRINT)
439.           && !ts_check_imprints(ctx->md_alg, ctx->imprint, ctx->imprint_len,
                   ^
440.                                 tst_info))
441.           goto err;

crypto/ts/ts_rsp_verify.c:444:10: Taking false branch
442.   
443.       /* Compute and check message imprints. */
444.       if ((ctx->flags & TS_VFY_DATA)
                ^
445.           && (!ts_compute_imprint(ctx->data, tst_info,
446.                                   &md_alg, &imprint, &imprint_len)

crypto/ts/ts_rsp_verify.c:451:10: Taking false branch
449.   
450.       /* Check nonces. */
451.       if ((ctx->flags & TS_VFY_NONCE)
                ^
452.           && !ts_check_nonces(ctx->nonce, tst_info))
453.           goto err;

crypto/ts/ts_rsp_verify.c:456:10: Taking true branch
454.   
455.       /* Check whether TSA name and signer certificate match. */
456.       if ((ctx->flags & TS_VFY_SIGNER)
                ^
457.           && tsa_name && !ts_check_signer_name(tsa_name, signer)) {
458.           TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_TSA_NAME_MISMATCH);

crypto/ts/ts_rsp_verify.c:457:12: Taking true branch
455.       /* Check whether TSA name and signer certificate match. */
456.       if ((ctx->flags & TS_VFY_SIGNER)
457.           && tsa_name && !ts_check_signer_name(tsa_name, signer)) {
                  ^
458.           TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_TSA_NAME_MISMATCH);
459.           goto err;

crypto/ts/ts_rsp_verify.c:457:25: 
455.       /* Check whether TSA name and signer certificate match. */
456.       if ((ctx->flags & TS_VFY_SIGNER)
457. >         && tsa_name && !ts_check_signer_name(tsa_name, signer)) {
458.           TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_TSA_NAME_MISMATCH);
459.           goto err;

static int int_ts_RESP_verify_token(TS_VERIFY_CTX *ctx,
                                    PKCS7 *token, TS_TST_INFO *tst_info)
{
    X509 *signer = NULL;
    GENERAL_NAME *tsa_name = TS_TST_INFO_get_tsa(tst_info);
    X509_ALGOR *md_alg = NULL;
    unsigned char *imprint = NULL;
    unsigned imprint_len = 0;
    int ret = 0;
    if ((ctx->flags & TS_VFY_SIGNATURE)
        && !TS_RESP_verify_signature(token, ctx->certs, ctx->store, &signer))
        goto err;
    if ((ctx->flags & TS_VFY_VERSION)
        && TS_TST_INFO_get_version(tst_info) != 1) {
        TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_UNSUPPORTED_VERSION);
        goto err;
    }
    if ((ctx->flags & TS_VFY_POLICY)
        && !ts_check_policy(ctx->policy, tst_info))
        goto err;
    if ((ctx->flags & TS_VFY_IMPRINT)
        && !ts_check_imprints(ctx->md_alg, ctx->imprint, ctx->imprint_len,
                              tst_info))
        goto err;
    if ((ctx->flags & TS_VFY_DATA)
        && (!ts_compute_imprint(ctx->data, tst_info,
                                &md_alg, &imprint, &imprint_len)
            || !ts_check_imprints(md_alg, imprint, imprint_len, tst_info)))
        goto err;
    if ((ctx->flags & TS_VFY_NONCE)
        && !ts_check_nonces(ctx->nonce, tst_info))
        goto err;
    if ((ctx->flags & TS_VFY_SIGNER)
        && tsa_name && !ts_check_signer_name(tsa_name, signer)) {
        TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_TSA_NAME_MISMATCH);
        goto err;
    }
    if ((ctx->flags & TS_VFY_TSA_NAME)
        && !ts_check_signer_name(ctx->tsa_name, signer)) {
        TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_TSA_UNTRUSTED);
        goto err;
    }
    ret = 1;
 err:
    X509_free(signer);
    X509_ALGOR_free(md_alg);
    OPENSSL_free(imprint);
    return ret;
}
['static int int_ts_RESP_verify_token(TS_VERIFY_CTX *ctx,\n                                    PKCS7 *token, TS_TST_INFO *tst_info)\n{\n    X509 *signer = NULL;\n    GENERAL_NAME *tsa_name = TS_TST_INFO_get_tsa(tst_info);\n    X509_ALGOR *md_alg = NULL;\n    unsigned char *imprint = NULL;\n    unsigned imprint_len = 0;\n    int ret = 0;\n    if ((ctx->flags & TS_VFY_SIGNATURE)\n        && !TS_RESP_verify_signature(token, ctx->certs, ctx->store, &signer))\n        goto err;\n    if ((ctx->flags & TS_VFY_VERSION)\n        && TS_TST_INFO_get_version(tst_info) != 1) {\n        TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_UNSUPPORTED_VERSION);\n        goto err;\n    }\n    if ((ctx->flags & TS_VFY_POLICY)\n        && !ts_check_policy(ctx->policy, tst_info))\n        goto err;\n    if ((ctx->flags & TS_VFY_IMPRINT)\n        && !ts_check_imprints(ctx->md_alg, ctx->imprint, ctx->imprint_len,\n                              tst_info))\n        goto err;\n    if ((ctx->flags & TS_VFY_DATA)\n        && (!ts_compute_imprint(ctx->data, tst_info,\n                                &md_alg, &imprint, &imprint_len)\n            || !ts_check_imprints(md_alg, imprint, imprint_len, tst_info)))\n        goto err;\n    if ((ctx->flags & TS_VFY_NONCE)\n        && !ts_check_nonces(ctx->nonce, tst_info))\n        goto err;\n    if ((ctx->flags & TS_VFY_SIGNER)\n        && tsa_name && !ts_check_signer_name(tsa_name, signer)) {\n        TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_TSA_NAME_MISMATCH);\n        goto err;\n    }\n    if ((ctx->flags & TS_VFY_TSA_NAME)\n        && !ts_check_signer_name(ctx->tsa_name, signer)) {\n        TSerr(TS_F_INT_TS_RESP_VERIFY_TOKEN, TS_R_TSA_UNTRUSTED);\n        goto err;\n    }\n    ret = 1;\n err:\n    X509_free(signer);\n    X509_ALGOR_free(md_alg);\n    OPENSSL_free(imprint);\n    return ret;\n}', 'GENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a)\n{\n    return a->tsa;\n}', 'static int ts_check_policy(ASN1_OBJECT *req_oid, TS_TST_INFO *tst_info)\n{\n    ASN1_OBJECT *resp_oid = TS_TST_INFO_get_policy_id(tst_info);\n    if (OBJ_cmp(req_oid, resp_oid) != 0) {\n        TSerr(TS_F_TS_CHECK_POLICY, TS_R_POLICY_MISMATCH);\n        return 0;\n    }\n    return 1;\n}', 'ASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a)\n{\n    return a->policy_id;\n}', 'int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b)\n{\n    int ret;\n    ret = (a->length - b->length);\n    if (ret)\n        return (ret);\n    return (memcmp(a->data, b->data, a->length));\n}']