crypto/asn1/ameth_lib.c:224: error: NULL_DEREFERENCE
  pointer `ameth` last assigned on line 223 could be null and is dereferenced at line 224, column 13.
Showing all 59 steps of the trace


crypto/asn1/ameth_lib.c:198:1: start of procedure EVP_PKEY_asn1_find_str()
196.   }
197.   
198. > const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
199.                                                      const char *str, int len)
200.   {

crypto/asn1/ameth_lib.c:203:9: Taking true branch
201.       int i;
202.       const EVP_PKEY_ASN1_METHOD *ameth;
203.       if (len == -1)
               ^
204.           len = strlen(str);
205.       if (pe) {

crypto/asn1/ameth_lib.c:204:9: 
202.       const EVP_PKEY_ASN1_METHOD *ameth;
203.       if (len == -1)
204. >         len = strlen(str);
205.       if (pe) {
206.   #ifndef OPENSSL_NO_ENGINE

crypto/asn1/ameth_lib.c:205:9: Taking true branch
203.       if (len == -1)
204.           len = strlen(str);
205.       if (pe) {
               ^
206.   #ifndef OPENSSL_NO_ENGINE
207.           ENGINE *e;

crypto/asn1/ameth_lib.c:208:9: 
206.   #ifndef OPENSSL_NO_ENGINE
207.           ENGINE *e;
208. >         ameth = ENGINE_pkey_asn1_find_str(&e, str, len);
209.           if (ameth) {
210.               /*

crypto/engine/tb_asnmth.c:227:1: start of procedure ENGINE_pkey_asn1_find_str()
  225.   }
  226.   
  227. > const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe,
  228.                                                         const char *str,
  229.                                                         int len)

crypto/engine/tb_asnmth.c:232:5: 
  230.   {
  231.       ENGINE_FIND_STR fstr;
  232. >     fstr.e = NULL;
  233.       fstr.ameth = NULL;
  234.       fstr.str = str;

crypto/engine/tb_asnmth.c:233:5: 
  231.       ENGINE_FIND_STR fstr;
  232.       fstr.e = NULL;
  233. >     fstr.ameth = NULL;
  234.       fstr.str = str;
  235.       fstr.len = len;

crypto/engine/tb_asnmth.c:234:5: 
  232.       fstr.e = NULL;
  233.       fstr.ameth = NULL;
  234. >     fstr.str = str;
  235.       fstr.len = len;
  236.       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);

crypto/engine/tb_asnmth.c:235:5: 
  233.       fstr.ameth = NULL;
  234.       fstr.str = str;
  235. >     fstr.len = len;
  236.       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
  237.       engine_table_doall(pkey_asn1_meth_table, look_str_cb, &fstr);

crypto/engine/tb_asnmth.c:236:5: 
  234.       fstr.str = str;
  235.       fstr.len = len;
  236. >     CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
  237.       engine_table_doall(pkey_asn1_meth_table, look_str_cb, &fstr);
  238.       /* If found obtain a structural reference to engine */

crypto/lock.c:417:1: start of procedure CRYPTO_lock()
    415.   }
    416.   
    417. > void CRYPTO_lock(int mode, int type, const char *file, int line)
    418.   {
    419.   #ifdef LOCK_DEBUG

crypto/lock.c:444:9: Taking false branch
    442.       }
    443.   #endif
    444.       if (type < 0) {
                   ^
    445.           if (dynlock_lock_callback != NULL) {
    446.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:455:16: Taking true branch
    453.               CRYPTO_destroy_dynlockid(type);
    454.           }
    455.       } else if (locking_callback != NULL)
                          ^
    456.           locking_callback(mode, type, file, line);
    457.   }

crypto/lock.c:456:9: Skipping __function_pointer__(): unresolved function pointer
    454.           }
    455.       } else if (locking_callback != NULL)
    456.           locking_callback(mode, type, file, line);
                   ^
    457.   }
    458.   

crypto/lock.c:444:5: 
    442.       }
    443.   #endif
    444. >     if (type < 0) {
    445.           if (dynlock_lock_callback != NULL) {
    446.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:457:1: return from a call to CRYPTO_lock
    455.       } else if (locking_callback != NULL)
    456.           locking_callback(mode, type, file, line);
    457. > }
    458.   
    459.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/engine/tb_asnmth.c:237:5: 
  235.       fstr.len = len;
  236.       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
  237. >     engine_table_doall(pkey_asn1_meth_table, look_str_cb, &fstr);
  238.       /* If found obtain a structural reference to engine */
  239.       if (fstr.e) {

crypto/engine/eng_table.c:348:1: start of procedure engine_table_doall()
    346.   static IMPLEMENT_LHASH_DOALL_ARG_FN(int_cb, ENGINE_PILE, ENGINE_PILE_DOALL)
    347.   
    348. > void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,
    349.                           void *arg)
    350.   {

crypto/engine/eng_table.c:352:5: 
    350.   {
    351.       ENGINE_PILE_DOALL dall;
    352. >     dall.cb = cb;
    353.       dall.arg = arg;
    354.       if (table)

crypto/engine/eng_table.c:353:5: 
    351.       ENGINE_PILE_DOALL dall;
    352.       dall.cb = cb;
    353. >     dall.arg = arg;
    354.       if (table)
    355.           lh_ENGINE_PILE_doall_arg(&table->piles,

crypto/engine/eng_table.c:354:9: Taking false branch
    352.       dall.cb = cb;
    353.       dall.arg = arg;
    354.       if (table)
                   ^
    355.           lh_ENGINE_PILE_doall_arg(&table->piles,
    356.                                    LHASH_DOALL_ARG_FN(int_cb),

crypto/engine/eng_table.c:354:5: 
    352.       dall.cb = cb;
    353.       dall.arg = arg;
    354. >     if (table)
    355.           lh_ENGINE_PILE_doall_arg(&table->piles,
    356.                                    LHASH_DOALL_ARG_FN(int_cb),

crypto/engine/eng_table.c:358:1: return from a call to engine_table_doall
    356.                                    LHASH_DOALL_ARG_FN(int_cb),
    357.                                    ENGINE_PILE_DOALL, &dall);
    358. > }

crypto/engine/tb_asnmth.c:239:9: Taking false branch
  237.       engine_table_doall(pkey_asn1_meth_table, look_str_cb, &fstr);
  238.       /* If found obtain a structural reference to engine */
  239.       if (fstr.e) {
                 ^
  240.           fstr.e->struct_ref++;
  241.           engine_ref_debug(fstr.e, 0, 1)

crypto/engine/tb_asnmth.c:243:5: 
  241.           engine_ref_debug(fstr.e, 0, 1)
  242.       }
  243. >     *pe = fstr.e;
  244.       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
  245.       return fstr.ameth;

crypto/engine/tb_asnmth.c:244:5: 
  242.       }
  243.       *pe = fstr.e;
  244. >     CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
  245.       return fstr.ameth;
  246.   }

crypto/lock.c:417:1: start of procedure CRYPTO_lock()
    415.   }
    416.   
    417. > void CRYPTO_lock(int mode, int type, const char *file, int line)
    418.   {
    419.   #ifdef LOCK_DEBUG

crypto/lock.c:444:9: Taking false branch
    442.       }
    443.   #endif
    444.       if (type < 0) {
                   ^
    445.           if (dynlock_lock_callback != NULL) {
    446.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:455:16: Taking true branch
    453.               CRYPTO_destroy_dynlockid(type);
    454.           }
    455.       } else if (locking_callback != NULL)
                          ^
    456.           locking_callback(mode, type, file, line);
    457.   }

crypto/lock.c:456:9: Skipping __function_pointer__(): unresolved function pointer
    454.           }
    455.       } else if (locking_callback != NULL)
    456.           locking_callback(mode, type, file, line);
                   ^
    457.   }
    458.   

crypto/lock.c:444:5: 
    442.       }
    443.   #endif
    444. >     if (type < 0) {
    445.           if (dynlock_lock_callback != NULL) {
    446.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:457:1: return from a call to CRYPTO_lock
    455.       } else if (locking_callback != NULL)
    456.           locking_callback(mode, type, file, line);
    457. > }
    458.   
    459.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/engine/tb_asnmth.c:245:5: 
  243.       *pe = fstr.e;
  244.       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
  245. >     return fstr.ameth;
  246.   }

crypto/engine/tb_asnmth.c:246:1: return from a call to ENGINE_pkey_asn1_find_str
  244.       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
  245.       return fstr.ameth;
  246. > }

crypto/asn1/ameth_lib.c:209:13: Taking false branch
207.           ENGINE *e;
208.           ameth = ENGINE_pkey_asn1_find_str(&e, str, len);
209.           if (ameth) {
                   ^
210.               /*
211.                * Convert structural into functional reference

crypto/asn1/ameth_lib.c:220:9: 
218.           }
219.   #endif
220. >         *pe = NULL;
221.       }
222.       for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {

crypto/asn1/ameth_lib.c:222:10: 
220.           *pe = NULL;
221.       }
222. >     for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
223.           ameth = EVP_PKEY_asn1_get0(i);
224.           if (ameth->pkey_flags & ASN1_PKEY_ALIAS)

crypto/asn1/ameth_lib.c:222:17: 
220.           *pe = NULL;
221.       }
222. >     for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
223.           ameth = EVP_PKEY_asn1_get0(i);
224.           if (ameth->pkey_flags & ASN1_PKEY_ALIAS)

crypto/asn1/ameth_lib.c:130:1: start of procedure EVP_PKEY_asn1_get_count()
  128.                                const EVP_PKEY_ASN1_METHOD *, ameth);
  129.   
  130. > int EVP_PKEY_asn1_get_count(void)
  131.   {
  132.       int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *);

crypto/asn1/ameth_lib.c:132:5: 
  130.   int EVP_PKEY_asn1_get_count(void)
  131.   {
  132. >     int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *);
  133.       if (app_methods)
  134.           num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);

crypto/asn1/ameth_lib.c:133:9: Taking false branch
  131.   {
  132.       int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *);
  133.       if (app_methods)
                 ^
  134.           num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);
  135.       return num;

crypto/asn1/ameth_lib.c:135:5: 
  133.       if (app_methods)
  134.           num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);
  135. >     return num;
  136.   }
  137.   

crypto/asn1/ameth_lib.c:136:1: return from a call to EVP_PKEY_asn1_get_count
  134.           num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);
  135.       return num;
  136. > }
  137.   
  138.   const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)

crypto/asn1/ameth_lib.c:222:17: Loop condition is true. Entering loop body
220.           *pe = NULL;
221.       }
222.       for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
                       ^
223.           ameth = EVP_PKEY_asn1_get0(i);
224.           if (ameth->pkey_flags & ASN1_PKEY_ALIAS)

crypto/asn1/ameth_lib.c:223:9: 
221.       }
222.       for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
223. >         ameth = EVP_PKEY_asn1_get0(i);
224.           if (ameth->pkey_flags & ASN1_PKEY_ALIAS)
225.               continue;

crypto/asn1/ameth_lib.c:138:1: start of procedure EVP_PKEY_asn1_get0()
  136.   }
  137.   
  138. > const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)
  139.   {
  140.       int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *);

crypto/asn1/ameth_lib.c:140:5: 
  138.   const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)
  139.   {
  140. >     int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *);
  141.       if (idx < 0)
  142.           return NULL;

crypto/asn1/ameth_lib.c:141:9: Taking false branch
  139.   {
  140.       int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *);
  141.       if (idx < 0)
                 ^
  142.           return NULL;
  143.       if (idx < num)

crypto/asn1/ameth_lib.c:143:9: Taking false branch
  141.       if (idx < 0)
  142.           return NULL;
  143.       if (idx < num)
                 ^
  144.           return standard_methods[idx];
  145.       idx -= num;

crypto/asn1/ameth_lib.c:145:5: 
  143.       if (idx < num)
  144.           return standard_methods[idx];
  145. >     idx -= num;
  146.       return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
  147.   }

crypto/asn1/ameth_lib.c:146:12: Condition is true
  144.           return standard_methods[idx];
  145.       idx -= num;
  146.       return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
                    ^
  147.   }
  148.   

crypto/asn1/ameth_lib.c:146:5: 
  144.           return standard_methods[idx];
  145.       idx -= num;
  146. >     return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
  147.   }
  148.   

crypto/stack/stack.c:347:1: start of procedure sk_value()
    345.   }
    346.   
    347. > void *sk_value(const _STACK *st, int i)
    348.   {
    349.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:349:10: Taking true branch
    347.   void *sk_value(const _STACK *st, int i)
    348.   {
    349.       if (!st || (i < 0) || (i >= st->num))
                    ^
    350.           return NULL;
    351.       return st->data[i];

crypto/stack/stack.c:350:9: 
    348.   {
    349.       if (!st || (i < 0) || (i >= st->num))
    350. >         return NULL;
    351.       return st->data[i];
    352.   }

crypto/stack/stack.c:352:1: return from a call to sk_value
    350.           return NULL;
    351.       return st->data[i];
    352. > }
    353.   
    354.   void *sk_set(_STACK *st, int i, void *value)

crypto/asn1/ameth_lib.c:147:1: return from a call to EVP_PKEY_asn1_get0
  145.       idx -= num;
  146.       return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
  147. > }
  148.   
  149.   static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type)

crypto/asn1/ameth_lib.c:224:13: 
222.       for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
223.           ameth = EVP_PKEY_asn1_get0(i);
224. >         if (ameth->pkey_flags & ASN1_PKEY_ALIAS)
225.               continue;
226.           if (((int)strlen(ameth->pem_str) == len) &&

const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
                                                   const char *str, int len)
{
    int i;
    const EVP_PKEY_ASN1_METHOD *ameth;
    if (len == -1)
        len = strlen(str);
    if (pe) {
#ifndef OPENSSL_NO_ENGINE
        ENGINE *e;
        ameth = ENGINE_pkey_asn1_find_str(&e, str, len);
        if (ameth) {
            if (!ENGINE_init(e))
                ameth = NULL;
            ENGINE_free(e);
            *pe = e;
            return ameth;
        }
#endif
        *pe = NULL;
    }
    for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
        ameth = EVP_PKEY_asn1_get0(i);
        if (ameth->pkey_flags & ASN1_PKEY_ALIAS)
            continue;
        if (((int)strlen(ameth->pem_str) == len) &&
            !strncasecmp(ameth->pem_str, str, len))
            return ameth;
    }
    return NULL;
}
['const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,\n                                                   const char *str, int len)\n{\n    int i;\n    const EVP_PKEY_ASN1_METHOD *ameth;\n    if (len == -1)\n        len = strlen(str);\n    if (pe) {\n#ifndef OPENSSL_NO_ENGINE\n        ENGINE *e;\n        ameth = ENGINE_pkey_asn1_find_str(&e, str, len);\n        if (ameth) {\n            if (!ENGINE_init(e))\n                ameth = NULL;\n            ENGINE_free(e);\n            *pe = e;\n            return ameth;\n        }\n#endif\n        *pe = NULL;\n    }\n    for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {\n        ameth = EVP_PKEY_asn1_get0(i);\n        if (ameth->pkey_flags & ASN1_PKEY_ALIAS)\n            continue;\n        if (((int)strlen(ameth->pem_str) == len) &&\n            !strncasecmp(ameth->pem_str, str, len))\n            return ameth;\n    }\n    return NULL;\n}', 'const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe,\n                                                      const char *str,\n                                                      int len)\n{\n    ENGINE_FIND_STR fstr;\n    fstr.e = NULL;\n    fstr.ameth = NULL;\n    fstr.str = str;\n    fstr.len = len;\n    CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);\n    engine_table_doall(pkey_asn1_meth_table, look_str_cb, &fstr);\n    if (fstr.e) {\n        fstr.e->struct_ref++;\n        engine_ref_debug(fstr.e, 0, 1)\n    }\n    *pe = fstr.e;\n    CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);\n    return fstr.ameth;\n}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n{\n#ifdef LOCK_DEBUG\n    {\n        CRYPTO_THREADID id;\n        char *rw_text, *operation_text;\n        if (mode & CRYPTO_LOCK)\n            operation_text = "lock  ";\n        else if (mode & CRYPTO_UNLOCK)\n            operation_text = "unlock";\n        else\n            operation_text = "ERROR ";\n        if (mode & CRYPTO_READ)\n            rw_text = "r";\n        else if (mode & CRYPTO_WRITE)\n            rw_text = "w";\n        else\n            rw_text = "ERROR";\n        CRYPTO_THREADID_current(&id);\n        fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\\n",\n                CRYPTO_THREADID_hash(&id), rw_text, operation_text,\n                CRYPTO_get_lock_name(type), file, line);\n    }\n#endif\n    if (type < 0) {\n        if (dynlock_lock_callback != NULL) {\n            struct CRYPTO_dynlock_value *pointer\n                = CRYPTO_get_dynlock_value(type);\n            OPENSSL_assert(pointer != NULL);\n            dynlock_lock_callback(mode, pointer, file, line);\n            CRYPTO_destroy_dynlockid(type);\n        }\n    } else if (locking_callback != NULL)\n        locking_callback(mode, type, file, line);\n}', 'void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,\n                        void *arg)\n{\n    ENGINE_PILE_DOALL dall;\n    dall.cb = cb;\n    dall.arg = arg;\n    if (table)\n        lh_ENGINE_PILE_doall_arg(&table->piles,\n                                 LHASH_DOALL_ARG_FN(int_cb),\n                                 ENGINE_PILE_DOALL, &dall);\n}', 'int EVP_PKEY_asn1_get_count(void)\n{\n    int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *);\n    if (app_methods)\n        num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);\n    return num;\n}', 'const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx)\n{\n    int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *);\n    if (idx < 0)\n        return NULL;\n    if (idx < num)\n        return standard_methods[idx];\n    idx -= num;\n    return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);\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}']