crypto/modes/siv128.c:177: error: NULL_DEREFERENCE
  pointer `cbc_name` last assigned on line 173 could be null and is dereferenced by call to `strlen()` at line 177, column 50.
Showing all 10 steps of the trace


crypto/modes/siv128.c:166:1: start of procedure CRYPTO_siv128_init()
164.    * Initialise an existing SIV128_CONTEXT
165.    */
166. > int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,
167.                          const EVP_CIPHER* cbc, const EVP_CIPHER* ctr)
168.   {

crypto/modes/siv128.c:169:5: 
167.                          const EVP_CIPHER* cbc, const EVP_CIPHER* ctr)
168.   {
169. >     static const unsigned char zero[SIV_LEN] = { 0 };
170.       size_t out_len = SIV_LEN;
171.       EVP_MAC_CTX *mac_ctx = NULL;

crypto/modes/siv128.c:170:5: 
168.   {
169.       static const unsigned char zero[SIV_LEN] = { 0 };
170. >     size_t out_len = SIV_LEN;
171.       EVP_MAC_CTX *mac_ctx = NULL;
172.       OSSL_PARAM params[3];

crypto/modes/siv128.c:171:5: 
169.       static const unsigned char zero[SIV_LEN] = { 0 };
170.       size_t out_len = SIV_LEN;
171. >     EVP_MAC_CTX *mac_ctx = NULL;
172.       OSSL_PARAM params[3];
173.       const char *cbc_name = EVP_CIPHER_name(cbc);

crypto/modes/siv128.c:173:5: 
171.       EVP_MAC_CTX *mac_ctx = NULL;
172.       OSSL_PARAM params[3];
173. >     const char *cbc_name = EVP_CIPHER_name(cbc);
174.   
175.       params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER,

crypto/evp/evp_lib.c:433:1: start of procedure EVP_CIPHER_name()
  431.   }
  432.   
  433. > const char *EVP_CIPHER_name(const EVP_CIPHER *cipher)
  434.   {
  435.       if (cipher->prov != NULL)

crypto/evp/evp_lib.c:435:9: Taking false branch
  433.   const char *EVP_CIPHER_name(const EVP_CIPHER *cipher)
  434.   {
  435.       if (cipher->prov != NULL)
                 ^
  436.           return cipher->name;
  437.   #ifndef FIPS_MODE

crypto/evp/evp_lib.c:440:5: 
  438.       return OBJ_nid2sn(EVP_CIPHER_nid(cipher));
  439.   #else
  440. >     return NULL;
  441.   #endif
  442.   }

crypto/evp/evp_lib.c:442:1: return from a call to EVP_CIPHER_name
  440.       return NULL;
  441.   #endif
  442. > }
  443.   
  444.   const OSSL_PROVIDER *EVP_CIPHER_provider(const EVP_CIPHER *cipher)

crypto/modes/siv128.c:175:5: 
173.       const char *cbc_name = EVP_CIPHER_name(cbc);
174.   
175. >     params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER,
176.                                                    (char *)cbc_name,
177.                                                    strlen(cbc_name) + 1);

int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,
                       const EVP_CIPHER* cbc, const EVP_CIPHER* ctr)
{
    static const unsigned char zero[SIV_LEN] = { 0 };
    size_t out_len = SIV_LEN;
    EVP_MAC_CTX *mac_ctx = NULL;
    OSSL_PARAM params[3];
    const char *cbc_name = EVP_CIPHER_name(cbc);
    params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER,
                                                 (char *)cbc_name,
                                                 strlen(cbc_name) + 1);
    params[1] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,
                                                  (void *)key, klen);
    params[2] = OSSL_PARAM_construct_end();
    memset(&ctx->d, 0, sizeof(ctx->d));
    ctx->cipher_ctx = NULL;
    ctx->mac_ctx_init = NULL;
    if (key == NULL || cbc == NULL || ctr == NULL
            || (ctx->cipher_ctx = EVP_CIPHER_CTX_new()) == NULL
            || (ctx->mac =
                EVP_MAC_fetch(NULL, OSSL_MAC_NAME_CMAC, NULL)) == NULL
            || (ctx->mac_ctx_init = EVP_MAC_CTX_new(ctx->mac)) == NULL
            || !EVP_MAC_CTX_set_params(ctx->mac_ctx_init, params)
            || !EVP_EncryptInit_ex(ctx->cipher_ctx, ctr, NULL, key + klen, NULL)
            || (mac_ctx = EVP_MAC_CTX_dup(ctx->mac_ctx_init)) == NULL
            || !EVP_MAC_update(mac_ctx, zero, sizeof(zero))
            || !EVP_MAC_final(mac_ctx, ctx->d.byte, &out_len,
                              sizeof(ctx->d.byte))) {
        EVP_CIPHER_CTX_free(ctx->cipher_ctx);
        EVP_MAC_CTX_free(ctx->mac_ctx_init);
        EVP_MAC_CTX_free(mac_ctx);
        EVP_MAC_free(ctx->mac);
        return 0;
    }
    EVP_MAC_CTX_free(mac_ctx);
    ctx->final_ret = -1;
    ctx->crypto_ok = 1;
    return 1;
}
['int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen,\n                       const EVP_CIPHER* cbc, const EVP_CIPHER* ctr)\n{\n    static const unsigned char zero[SIV_LEN] = { 0 };\n    size_t out_len = SIV_LEN;\n    EVP_MAC_CTX *mac_ctx = NULL;\n    OSSL_PARAM params[3];\n    const char *cbc_name = EVP_CIPHER_name(cbc);\n    params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER,\n                                                 (char *)cbc_name,\n                                                 strlen(cbc_name) + 1);\n    params[1] = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,\n                                                  (void *)key, klen);\n    params[2] = OSSL_PARAM_construct_end();\n    memset(&ctx->d, 0, sizeof(ctx->d));\n    ctx->cipher_ctx = NULL;\n    ctx->mac_ctx_init = NULL;\n    if (key == NULL || cbc == NULL || ctr == NULL\n            || (ctx->cipher_ctx = EVP_CIPHER_CTX_new()) == NULL\n            || (ctx->mac =\n                EVP_MAC_fetch(NULL, OSSL_MAC_NAME_CMAC, NULL)) == NULL\n            || (ctx->mac_ctx_init = EVP_MAC_CTX_new(ctx->mac)) == NULL\n            || !EVP_MAC_CTX_set_params(ctx->mac_ctx_init, params)\n            || !EVP_EncryptInit_ex(ctx->cipher_ctx, ctr, NULL, key + klen, NULL)\n            || (mac_ctx = EVP_MAC_CTX_dup(ctx->mac_ctx_init)) == NULL\n            || !EVP_MAC_update(mac_ctx, zero, sizeof(zero))\n            || !EVP_MAC_final(mac_ctx, ctx->d.byte, &out_len,\n                              sizeof(ctx->d.byte))) {\n        EVP_CIPHER_CTX_free(ctx->cipher_ctx);\n        EVP_MAC_CTX_free(ctx->mac_ctx_init);\n        EVP_MAC_CTX_free(mac_ctx);\n        EVP_MAC_free(ctx->mac);\n        return 0;\n    }\n    EVP_MAC_CTX_free(mac_ctx);\n    ctx->final_ret = -1;\n    ctx->crypto_ok = 1;\n    return 1;\n}', 'const char *EVP_CIPHER_name(const EVP_CIPHER *cipher)\n{\n    if (cipher->prov != NULL)\n        return cipher->name;\n#ifndef FIPS_MODE\n    return OBJ_nid2sn(EVP_CIPHER_nid(cipher));\n#else\n    return NULL;\n#endif\n}']