crypto/x509v3/v3_skey.c:150: error: MEMORY_LEAK
  memory dynamically allocated by call to `ASN1_OCTET_STRING_new()` at line 115, column 16 is not reachable after line 150, column 5.
Showing all 71 steps of the trace


crypto/x509v3/v3_skey.c:104:1: start of procedure s2i_skey_id()
102.   }
103.   
104. > static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
105.                                         X509V3_CTX *ctx, char *str)
106.   {

crypto/x509v3/v3_skey.c:112:9: Taking false branch
110.       unsigned int diglen;
111.   
112.       if (strcmp(str, "hash"))
               ^
113.           return s2i_ASN1_OCTET_STRING(method, ctx, str);
114.   

crypto/x509v3/v3_skey.c:115:9: 
113.           return s2i_ASN1_OCTET_STRING(method, ctx, str);
114.   
115. >     if ((oct = ASN1_OCTET_STRING_new()) == NULL) {
116.           X509V3err(X509V3_F_S2I_SKEY_ID, ERR_R_MALLOC_FAILURE);
117.           return NULL;

crypto/asn1/tasn_typ.c:77:1: start of procedure ASN1_OCTET_STRING_new()
  75.   }
  76.   
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)

crypto/asn1/asn1_lib.c:349:1: start of procedure ASN1_STRING_type_new()
    347.   }
    348.   
    349. > ASN1_STRING *ASN1_STRING_type_new(int type)
    350.   {
    351.       ASN1_STRING *ret;

crypto/asn1/asn1_lib.c:353:5: 
    351.       ASN1_STRING *ret;
    352.   
    353. >     ret = OPENSSL_zalloc(sizeof(*ret));
    354.       if (ret == NULL) {
    355.           ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);

crypto/mem.c:157:1: start of procedure CRYPTO_zalloc()
      155.   }
      156.   
      157. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
      158.   {
      159.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:159:5: 
      157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
      158.   {
      159. >     void *ret = CRYPTO_malloc(num, file, line);
      160.   
      161.       if (ret != NULL)

crypto/mem.c:120:1: start of procedure CRYPTO_malloc()
        118.   }
        119.   
        120. > void *CRYPTO_malloc(size_t num, const char *file, int line)
        121.   {
        122.       void *ret = NULL;

crypto/mem.c:122:5: 
        120.   void *CRYPTO_malloc(size_t num, const char *file, int line)
        121.   {
        122. >     void *ret = NULL;
        123.   
        124.       if (num <= 0)

crypto/mem.c:124:9: Taking false branch
        122.       void *ret = NULL;
        123.   
        124.       if (num <= 0)
                       ^
        125.           return NULL;
        126.   

crypto/mem.c:127:5: 
        125.           return NULL;
        126.   
        127. >     allow_customize = 0;
        128.   #ifdef CRYPTO_MDEBUG
        129.       if (call_malloc_debug) {

crypto/mem.c:137:5: 
        135.       }
        136.   #else
        137. >     (void)file;
        138.       (void)line;
        139.       ret = malloc(num);

crypto/mem.c:138:5: 
        136.   #else
        137.       (void)file;
        138. >     (void)line;
        139.       ret = malloc(num);
        140.   #endif

crypto/mem.c:139:5: 
        137.       (void)file;
        138.       (void)line;
        139. >     ret = malloc(num);
        140.   #endif
        141.   

crypto/mem.c:154:5: 
        152.   #endif
        153.   
        154. >     return ret;
        155.   }
        156.   

crypto/mem.c:155:1: return from a call to CRYPTO_malloc
        153.   
        154.       return ret;
        155. > }
        156.   
        157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:161:9: Taking true branch
      159.       void *ret = CRYPTO_malloc(num, file, line);
      160.   
      161.       if (ret != NULL)
                     ^
      162.           memset(ret, 0, num);
      163.       return ret;

crypto/mem.c:162:9: 
      160.   
      161.       if (ret != NULL)
      162. >         memset(ret, 0, num);
      163.       return ret;
      164.   }

crypto/mem.c:163:5: 
      161.       if (ret != NULL)
      162.           memset(ret, 0, num);
      163. >     return ret;
      164.   }
      165.   

crypto/mem.c:164:1: return from a call to CRYPTO_zalloc
      162.           memset(ret, 0, num);
      163.       return ret;
      164. > }
      165.   
      166.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/asn1/asn1_lib.c:354:9: Taking false branch
    352.   
    353.       ret = OPENSSL_zalloc(sizeof(*ret));
    354.       if (ret == NULL) {
                   ^
    355.           ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);
    356.           return (NULL);

crypto/asn1/asn1_lib.c:358:5: 
    356.           return (NULL);
    357.       }
    358. >     ret->type = type;
    359.       return (ret);
    360.   }

crypto/asn1/asn1_lib.c:359:5: 
    357.       }
    358.       ret->type = type;
    359. >     return (ret);
    360.   }
    361.   

crypto/asn1/asn1_lib.c:360:1: return from a call to ASN1_STRING_type_new
    358.       ret->type = type;
    359.       return (ret);
    360. > }
    361.   
    362.   void ASN1_STRING_free(ASN1_STRING *a)

crypto/asn1/tasn_typ.c:77:1: return from a call to ASN1_OCTET_STRING_new
  75.   }
  76.   
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)

crypto/x509v3/v3_skey.c:115:9: Taking false branch
113.           return s2i_ASN1_OCTET_STRING(method, ctx, str);
114.   
115.       if ((oct = ASN1_OCTET_STRING_new()) == NULL) {
               ^
116.           X509V3err(X509V3_F_S2I_SKEY_ID, ERR_R_MALLOC_FAILURE);
117.           return NULL;

crypto/x509v3/v3_skey.c:120:9: Taking true branch
118.       }
119.   
120.       if (ctx && (ctx->flags == CTX_TEST))
               ^
121.           return oct;
122.   

crypto/x509v3/v3_skey.c:120:17: Taking false branch
118.       }
119.   
120.       if (ctx && (ctx->flags == CTX_TEST))
                       ^
121.           return oct;
122.   

crypto/x509v3/v3_skey.c:123:10: Taking false branch
121.           return oct;
122.   
123.       if (!ctx || (!ctx->subject_req && !ctx->subject_cert)) {
                ^
124.           X509V3err(X509V3_F_S2I_SKEY_ID, X509V3_R_NO_PUBLIC_KEY);
125.           goto err;

crypto/x509v3/v3_skey.c:123:19: Taking false branch
121.           return oct;
122.   
123.       if (!ctx || (!ctx->subject_req && !ctx->subject_cert)) {
                         ^
124.           X509V3err(X509V3_F_S2I_SKEY_ID, X509V3_R_NO_PUBLIC_KEY);
125.           goto err;

crypto/x509v3/v3_skey.c:128:9: Taking true branch
126.       }
127.   
128.       if (ctx->subject_req)
               ^
129.           pk = ctx->subject_req->req_info.pubkey->public_key;
130.       else

crypto/x509v3/v3_skey.c:129:9: 
127.   
128.       if (ctx->subject_req)
129. >         pk = ctx->subject_req->req_info.pubkey->public_key;
130.       else
131.           pk = ctx->subject_cert->cert_info.key->public_key;

crypto/x509v3/v3_skey.c:133:10: Taking false branch
131.           pk = ctx->subject_cert->cert_info.key->public_key;
132.   
133.       if (!pk) {
                ^
134.           X509V3err(X509V3_F_S2I_SKEY_ID, X509V3_R_NO_PUBLIC_KEY);
135.           goto err;

crypto/x509v3/v3_skey.c:138:10: 
136.       }
137.   
138. >     if (!EVP_Digest
139.           (pk->data, pk->length, pkey_dig, &diglen, EVP_sha1(), NULL))
140.           goto err;

crypto/evp/m_sha1.c:154:1: start of procedure EVP_sha1()
  152.   };
  153.   
  154. > const EVP_MD *EVP_sha1(void)
  155.   {
  156.       return (&sha1_md);

crypto/evp/m_sha1.c:156:5: 
  154.   const EVP_MD *EVP_sha1(void)
  155.   {
  156. >     return (&sha1_md);
  157.   }
  158.   

crypto/evp/m_sha1.c:157:1: return from a call to EVP_sha1
  155.   {
  156.       return (&sha1_md);
  157. > }
  158.   
  159.   static int init224(EVP_MD_CTX *ctx)

crypto/evp/digest.c:351:1: start of procedure EVP_Digest()
  349.   }
  350.   
  351. > int EVP_Digest(const void *data, size_t count,
  352.                  unsigned char *md, unsigned int *size, const EVP_MD *type,
  353.                  ENGINE *impl)

crypto/evp/digest.c:355:5: 
  353.                  ENGINE *impl)
  354.   {
  355. >     EVP_MD_CTX *ctx = EVP_MD_CTX_new();
  356.       int ret;
  357.   

crypto/evp/digest.c:153:1: start of procedure EVP_MD_CTX_new()
    151.   }
    152.   
    153. > EVP_MD_CTX *EVP_MD_CTX_new(void)
    154.   {
    155.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:155:5: 
    153.   EVP_MD_CTX *EVP_MD_CTX_new(void)
    154.   {
    155. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
    156.   }
    157.   

crypto/mem.c:157:1: start of procedure CRYPTO_zalloc()
      155.   }
      156.   
      157. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
      158.   {
      159.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:159:5: 
      157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
      158.   {
      159. >     void *ret = CRYPTO_malloc(num, file, line);
      160.   
      161.       if (ret != NULL)

crypto/mem.c:120:1: start of procedure CRYPTO_malloc()
        118.   }
        119.   
        120. > void *CRYPTO_malloc(size_t num, const char *file, int line)
        121.   {
        122.       void *ret = NULL;

crypto/mem.c:122:5: 
        120.   void *CRYPTO_malloc(size_t num, const char *file, int line)
        121.   {
        122. >     void *ret = NULL;
        123.   
        124.       if (num <= 0)

crypto/mem.c:124:9: Taking false branch
        122.       void *ret = NULL;
        123.   
        124.       if (num <= 0)
                       ^
        125.           return NULL;
        126.   

crypto/mem.c:127:5: 
        125.           return NULL;
        126.   
        127. >     allow_customize = 0;
        128.   #ifdef CRYPTO_MDEBUG
        129.       if (call_malloc_debug) {

crypto/mem.c:137:5: 
        135.       }
        136.   #else
        137. >     (void)file;
        138.       (void)line;
        139.       ret = malloc(num);

crypto/mem.c:138:5: 
        136.   #else
        137.       (void)file;
        138. >     (void)line;
        139.       ret = malloc(num);
        140.   #endif

crypto/mem.c:139:5: 
        137.       (void)file;
        138.       (void)line;
        139. >     ret = malloc(num);
        140.   #endif
        141.   

crypto/mem.c:154:5: 
        152.   #endif
        153.   
        154. >     return ret;
        155.   }
        156.   

crypto/mem.c:155:1: return from a call to CRYPTO_malloc
        153.   
        154.       return ret;
        155. > }
        156.   
        157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:161:9: Taking false branch
      159.       void *ret = CRYPTO_malloc(num, file, line);
      160.   
      161.       if (ret != NULL)
                     ^
      162.           memset(ret, 0, num);
      163.       return ret;

crypto/mem.c:163:5: 
      161.       if (ret != NULL)
      162.           memset(ret, 0, num);
      163. >     return ret;
      164.   }
      165.   

crypto/mem.c:164:1: return from a call to CRYPTO_zalloc
      162.           memset(ret, 0, num);
      163.       return ret;
      164. > }
      165.   
      166.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:156:1: return from a call to EVP_MD_CTX_new
    154.   {
    155.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
    156. > }
    157.   
    158.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

crypto/evp/digest.c:358:9: Taking true branch
  356.       int ret;
  357.   
  358.       if (ctx == NULL)
                 ^
  359.           return 0;
  360.       EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_ONESHOT);

crypto/evp/digest.c:359:9: 
  357.   
  358.       if (ctx == NULL)
  359. >         return 0;
  360.       EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_ONESHOT);
  361.       ret = EVP_DigestInit_ex(ctx, type, impl)

crypto/evp/digest.c:367:1: return from a call to EVP_Digest
  365.   
  366.       return ret;
  367. > }
  368.   
  369.   int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2)

crypto/x509v3/v3_skey.c:138:10: Taking true branch
136.       }
137.   
138.       if (!EVP_Digest
                ^
139.           (pk->data, pk->length, pkey_dig, &diglen, EVP_sha1(), NULL))
140.           goto err;

crypto/x509v3/v3_skey.c:149:2: 
147.       return oct;
148.   
149. >  err:
150.       ASN1_OCTET_STRING_free(oct);
151.       return NULL;

crypto/x509v3/v3_skey.c:150:5: 
148.   
149.    err:
150. >     ASN1_OCTET_STRING_free(oct);
151.       return NULL;
152.   }

crypto/asn1/tasn_typ.c:77:1: start of procedure ASN1_OCTET_STRING_free()
  75.   }
  76.   
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)

crypto/asn1/asn1_lib.c:362:1: start of procedure ASN1_STRING_free()
    360.   }
    361.   
    362. > void ASN1_STRING_free(ASN1_STRING *a)
    363.   {
    364.       if (a == NULL)

crypto/asn1/asn1_lib.c:364:9: Taking false branch
    362.   void ASN1_STRING_free(ASN1_STRING *a)
    363.   {
    364.       if (a == NULL)
                   ^
    365.           return;
    366.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))

crypto/asn1/asn1_lib.c:366:11: Taking false branch
    364.       if (a == NULL)
    365.           return;
    366.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))
                     ^
    367.           OPENSSL_free(a->data);
    368.       if (!(a->flags & ASN1_STRING_FLAG_EMBED))

crypto/asn1/asn1_lib.c:368:11: Taking false branch
    366.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))
    367.           OPENSSL_free(a->data);
    368.       if (!(a->flags & ASN1_STRING_FLAG_EMBED))
                     ^
    369.           OPENSSL_free(a);
    370.   }

crypto/asn1/asn1_lib.c:368:5: 
    366.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))
    367.           OPENSSL_free(a->data);
    368. >     if (!(a->flags & ASN1_STRING_FLAG_EMBED))
    369.           OPENSSL_free(a);
    370.   }

crypto/asn1/asn1_lib.c:370:1: return from a call to ASN1_STRING_free
    368.       if (!(a->flags & ASN1_STRING_FLAG_EMBED))
    369.           OPENSSL_free(a);
    370. > }
    371.   
    372.   void ASN1_STRING_clear_free(ASN1_STRING *a)

crypto/asn1/tasn_typ.c:77:1: return from a call to ASN1_OCTET_STRING_free
  75.   }
  76.   
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)

static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,
                                      X509V3_CTX *ctx, char *str)
{
    ASN1_OCTET_STRING *oct;
    ASN1_BIT_STRING *pk;
    unsigned char pkey_dig[EVP_MAX_MD_SIZE];
    unsigned int diglen;
    if (strcmp(str, "hash"))
        return s2i_ASN1_OCTET_STRING(method, ctx, str);
    if ((oct = ASN1_OCTET_STRING_new()) == NULL) {
        X509V3err(X509V3_F_S2I_SKEY_ID, ERR_R_MALLOC_FAILURE);
        return NULL;
    }
    if (ctx && (ctx->flags == CTX_TEST))
        return oct;
    if (!ctx || (!ctx->subject_req && !ctx->subject_cert)) {
        X509V3err(X509V3_F_S2I_SKEY_ID, X509V3_R_NO_PUBLIC_KEY);
        goto err;
    }
    if (ctx->subject_req)
        pk = ctx->subject_req->req_info.pubkey->public_key;
    else
        pk = ctx->subject_cert->cert_info.key->public_key;
    if (!pk) {
        X509V3err(X509V3_F_S2I_SKEY_ID, X509V3_R_NO_PUBLIC_KEY);
        goto err;
    }
    if (!EVP_Digest
        (pk->data, pk->length, pkey_dig, &diglen, EVP_sha1(), NULL))
        goto err;
    if (!ASN1_OCTET_STRING_set(oct, pkey_dig, diglen)) {
        X509V3err(X509V3_F_S2I_SKEY_ID, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    return oct;
 err:
    ASN1_OCTET_STRING_free(oct);
    return NULL;
}
['static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method,\n                                      X509V3_CTX *ctx, char *str)\n{\n    ASN1_OCTET_STRING *oct;\n    ASN1_BIT_STRING *pk;\n    unsigned char pkey_dig[EVP_MAX_MD_SIZE];\n    unsigned int diglen;\n    if (strcmp(str, "hash"))\n        return s2i_ASN1_OCTET_STRING(method, ctx, str);\n    if ((oct = ASN1_OCTET_STRING_new()) == NULL) {\n        X509V3err(X509V3_F_S2I_SKEY_ID, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    if (ctx && (ctx->flags == CTX_TEST))\n        return oct;\n    if (!ctx || (!ctx->subject_req && !ctx->subject_cert)) {\n        X509V3err(X509V3_F_S2I_SKEY_ID, X509V3_R_NO_PUBLIC_KEY);\n        goto err;\n    }\n    if (ctx->subject_req)\n        pk = ctx->subject_req->req_info.pubkey->public_key;\n    else\n        pk = ctx->subject_cert->cert_info.key->public_key;\n    if (!pk) {\n        X509V3err(X509V3_F_S2I_SKEY_ID, X509V3_R_NO_PUBLIC_KEY);\n        goto err;\n    }\n    if (!EVP_Digest\n        (pk->data, pk->length, pkey_dig, &diglen, EVP_sha1(), NULL))\n        goto err;\n    if (!ASN1_OCTET_STRING_set(oct, pkey_dig, diglen)) {\n        X509V3err(X509V3_F_S2I_SKEY_ID, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    return oct;\n err:\n    ASN1_OCTET_STRING_free(oct);\n    return NULL;\n}', 'IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)', 'ASN1_STRING *ASN1_STRING_type_new(int type)\n{\n    ASN1_STRING *ret;\n    ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL) {\n        ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    ret->type = type;\n    return (ret);\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (num <= 0)\n        return NULL;\n    allow_customize = 0;\n#ifdef CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'const EVP_MD *EVP_sha1(void)\n{\n    return (&sha1_md);\n}', 'int EVP_Digest(const void *data, size_t count,\n               unsigned char *md, unsigned int *size, const EVP_MD *type,\n               ENGINE *impl)\n{\n    EVP_MD_CTX *ctx = EVP_MD_CTX_new();\n    int ret;\n    if (ctx == NULL)\n        return 0;\n    EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_ONESHOT);\n    ret = EVP_DigestInit_ex(ctx, type, impl)\n        && EVP_DigestUpdate(ctx, data, count)\n        && EVP_DigestFinal_ex(ctx, md, size);\n    EVP_MD_CTX_free(ctx);\n    return ret;\n}', 'EVP_MD_CTX *EVP_MD_CTX_new(void)\n{\n    return OPENSSL_zalloc(sizeof(EVP_MD_CTX));\n}', 'void ASN1_STRING_free(ASN1_STRING *a)\n{\n    if (a == NULL)\n        return;\n    if (!(a->flags & ASN1_STRING_FLAG_NDEF))\n        OPENSSL_free(a->data);\n    if (!(a->flags & ASN1_STRING_FLAG_EMBED))\n        OPENSSL_free(a);\n}']