engines/e_ncipher.c:869: error: NULL_DEREFERENCE
  pointer `res->pkey.rsa` last assigned on line 868 could be null and is dereferenced at line 869, column 4.
Showing all 48 steps of the trace


engines/e_ncipher.c:848:1: start of procedure hwcrhk_load_pubkey()
846.   	}
847.   
848. > static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
849.   	UI_METHOD *ui_method, void *callback_data)
850.   	{

engines/e_ncipher.c:851:2: 
849.   	UI_METHOD *ui_method, void *callback_data)
850.   	{
851. > 	EVP_PKEY *res = NULL;
852.   
853.   #ifndef OPENSSL_NO_RSA

engines/e_ncipher.c:854:9: Skipping hwcrhk_load_privkey(): empty list of specs
852.   
853.   #ifndef OPENSSL_NO_RSA
854.           res = hwcrhk_load_privkey(eng, key_id,
               ^
855.                   ui_method, callback_data);
856.   #endif

engines/e_ncipher.c:858:6: Taking true branch
856.   #endif
857.   
858.   	if (res)
            ^
859.   		switch(res->type)
860.   			{

engines/e_ncipher.c:859:3: 
857.   
858.   	if (res)
859. > 		switch(res->type)
860.   			{
861.   #ifndef OPENSSL_NO_RSA

engines/e_ncipher.c:862:3: Switch condition is true. Entering switch case
860.   			{
861.   #ifndef OPENSSL_NO_RSA
862.   		case EVP_PKEY_RSA:
         ^
863.   			{
864.   			RSA *rsa = NULL;

engines/e_ncipher.c:864:4: 
862.   		case EVP_PKEY_RSA:
863.   			{
864. > 			RSA *rsa = NULL;
865.   
866.   			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);

engines/e_ncipher.c:866:4: 
864.   			RSA *rsa = NULL;
865.   
866. > 			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
867.   			rsa = res->pkey.rsa;
868.   			res->pkey.rsa = RSA_new();

crypto/cryptlib.c:448:1: start of procedure CRYPTO_lock()
  446.   	}
  447.   
  448. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  449.   	{
  450.   #ifdef LOCK_DEBUG

crypto/cryptlib.c:473:6: Taking false branch
  471.   		}
  472.   #endif
  473.   	if (type < 0)
              ^
  474.   		{
  475.   		if (dynlock_lock_callback != NULL)

crypto/cryptlib.c:488:7: Taking true branch
  486.   		}
  487.   	else
  488.   		if (locking_callback != NULL)
               ^
  489.   			locking_callback(mode,type,file,line);
  490.   	}

crypto/cryptlib.c:489:4: Skipping __function_pointer__(): unresolved function pointer
  487.   	else
  488.   		if (locking_callback != NULL)
  489.   			locking_callback(mode,type,file,line);
            ^
  490.   	}
  491.   

crypto/cryptlib.c:473:2: 
  471.   		}
  472.   #endif
  473. > 	if (type < 0)
  474.   		{
  475.   		if (dynlock_lock_callback != NULL)

crypto/cryptlib.c:490:2: return from a call to CRYPTO_lock
  488.   		if (locking_callback != NULL)
  489.   			locking_callback(mode,type,file,line);
  490.   	}
          ^
  491.   
  492.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

engines/e_ncipher.c:867:4: 
865.   
866.   			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
867. > 			rsa = res->pkey.rsa;
868.   			res->pkey.rsa = RSA_new();
869.   			res->pkey.rsa->n = rsa->n;

engines/e_ncipher.c:868:4: 
866.   			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
867.   			rsa = res->pkey.rsa;
868. > 			res->pkey.rsa = RSA_new();
869.   			res->pkey.rsa->n = rsa->n;
870.   			res->pkey.rsa->e = rsa->e;

crypto/rsa/rsa_lib.c:71:1: start of procedure RSA_new()
  69.   static const RSA_METHOD *default_RSA_meth=NULL;
  70.   
  71. > RSA *RSA_new(void)
  72.   	{
  73.   	return(RSA_new_method(NULL));

crypto/rsa/rsa_lib.c:73:2: 
  71.   RSA *RSA_new(void)
  72.   	{
  73. > 	return(RSA_new_method(NULL));
  74.   	}
  75.   

crypto/rsa/rsa_lib.c:121:1: start of procedure RSA_new_method()
    119.   	}
    120.   
    121. > RSA *RSA_new_method(ENGINE *engine)
    122.   	{
    123.   	RSA *ret;

crypto/rsa/rsa_lib.c:125:2: 
    123.   	RSA *ret;
    124.   
    125. > 	ret=(RSA *)OPENSSL_malloc(sizeof(RSA));
    126.   	if (ret == NULL)
    127.   		{

crypto/mem.c:289:1: start of procedure CRYPTO_malloc()
      287.   	}
      288.   
      289. > void *CRYPTO_malloc(int num, const char *file, int line)
      290.   	{
      291.   	void *ret = NULL;

crypto/mem.c:291:2: 
      289.   void *CRYPTO_malloc(int num, const char *file, int line)
      290.   	{
      291. > 	void *ret = NULL;
      292.   	extern unsigned char cleanse_ctr;
      293.   

crypto/mem.c:294:2: 
      292.   	extern unsigned char cleanse_ctr;
      293.   
      294. > 	allow_customize = 0;
      295.   	if (malloc_debug_func != NULL)
      296.   		{

crypto/mem.c:295:6: Taking true branch
      293.   
      294.   	allow_customize = 0;
      295.   	if (malloc_debug_func != NULL)
                  ^
      296.   		{
      297.   		allow_customize_debug = 0;

crypto/mem.c:297:3: 
      295.   	if (malloc_debug_func != NULL)
      296.   		{
      297. > 		allow_customize_debug = 0;
      298.   		malloc_debug_func(NULL, num, file, line, 0);
      299.   		}

crypto/mem.c:298:3: Skipping __function_pointer__(): unresolved function pointer
      296.   		{
      297.   		allow_customize_debug = 0;
      298.   		malloc_debug_func(NULL, num, file, line, 0);
               ^
      299.   		}
      300.   	ret = malloc_ex_func(num,file,line);

crypto/mem.c:300:2: Skipping __function_pointer__(): unresolved function pointer
      298.   		malloc_debug_func(NULL, num, file, line, 0);
      299.   		}
      300.   	ret = malloc_ex_func(num,file,line);
              ^
      301.   #ifdef LEVITTE_DEBUG_MEM
      302.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);

crypto/mem.c:304:6: Taking true branch
      302.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
      303.   #endif
      304.   	if (malloc_debug_func != NULL)
                  ^
      305.   		malloc_debug_func(ret, num, file, line, 1);
      306.   

crypto/mem.c:305:3: Skipping __function_pointer__(): unresolved function pointer
      303.   #endif
      304.   	if (malloc_debug_func != NULL)
      305.   		malloc_debug_func(ret, num, file, line, 1);
               ^
      306.   
      307.           /* Create a dependency on the value of 'cleanse_ctr' so our memory

crypto/mem.c:310:12: Taking false branch
      308.            * sanitisation function can't be optimised out. NB: We only do
      309.            * this for >2Kb so the overhead doesn't bother us. */
      310.           if(ret && (num > 2048))
                        ^
      311.                   ((unsigned char *)ret)[0] = cleanse_ctr;
      312.   

crypto/mem.c:313:2: 
      311.                   ((unsigned char *)ret)[0] = cleanse_ctr;
      312.   
      313. > 	return ret;
      314.   	}
      315.   

crypto/mem.c:314:2: return from a call to CRYPTO_malloc
      312.   
      313.   	return ret;
      314.   	}
              ^
      315.   
      316.   void *CRYPTO_realloc(void *str, int num, const char *file, int line)

crypto/rsa/rsa_lib.c:126:6: Taking true branch
    124.   
    125.   	ret=(RSA *)OPENSSL_malloc(sizeof(RSA));
    126.   	if (ret == NULL)
                ^
    127.   		{
    128.   		RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);

crypto/rsa/rsa_lib.c:128:3: 
    126.   	if (ret == NULL)
    127.   		{
    128. > 		RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
    129.   		return NULL;
    130.   		}

crypto/err/err.c:617:1: start of procedure ERR_put_error()
      615.   /********************************************************/
      616.   
      617. > void ERR_put_error(int lib, int func, int reason, const char *file,
      618.   	     int line)
      619.   	{

crypto/err/err.c:641:2: Skipping ERR_get_state(): empty list of specs
      639.   	}
      640.   #endif
      641.   	es=ERR_get_state();
              ^
      642.   
      643.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:643:2: 
      641.   	es=ERR_get_state();
      642.   
      643. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
      644.   	if (es->top == es->bottom)
      645.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:644:6: Taking false branch
      642.   
      643.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
      644.   	if (es->top == es->bottom)
                  ^
      645.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      646.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);

crypto/err/err.c:646:2: 
      644.   	if (es->top == es->bottom)
      645.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      646. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      647.   	es->err_file[es->top]=file;
      648.   	es->err_line[es->top]=line;

crypto/err/err.c:647:2: 
      645.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      646.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      647. > 	es->err_file[es->top]=file;
      648.   	es->err_line[es->top]=line;
      649.   	err_clear_data(es,es->top);

crypto/err/err.c:648:2: 
      646.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      647.   	es->err_file[es->top]=file;
      648. > 	es->err_line[es->top]=line;
      649.   	err_clear_data(es,es->top);
      650.   	}

crypto/err/err.c:649:2: Taking true branch
      647.   	es->err_file[es->top]=file;
      648.   	es->err_line[es->top]=line;
      649.   	err_clear_data(es,es->top);
              ^
      650.   	}
      651.   

crypto/err/err.c:649:2: Taking false branch
      647.   	es->err_file[es->top]=file;
      648.   	es->err_line[es->top]=line;
      649.   	err_clear_data(es,es->top);
              ^
      650.   	}
      651.   

crypto/err/err.c:650:2: return from a call to ERR_put_error
      648.   	es->err_line[es->top]=line;
      649.   	err_clear_data(es,es->top);
      650.   	}
              ^
      651.   
      652.   void ERR_clear_error(void)

crypto/rsa/rsa_lib.c:129:3: 
    127.   		{
    128.   		RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
    129. > 		return NULL;
    130.   		}
    131.   

crypto/rsa/rsa_lib.c:185:2: return from a call to RSA_new_method
    183.   		}
    184.   	return(ret);
    185.   	}
            ^
    186.   
    187.   void RSA_free(RSA *r)

crypto/rsa/rsa_lib.c:74:2: return from a call to RSA_new
  72.   	{
  73.   	return(RSA_new_method(NULL));
  74.   	}
         ^
  75.   
  76.   void RSA_set_default_method(const RSA_METHOD *meth)

engines/e_ncipher.c:869:4: 
867.   			rsa = res->pkey.rsa;
868.   			res->pkey.rsa = RSA_new();
869. > 			res->pkey.rsa->n = rsa->n;
870.   			res->pkey.rsa->e = rsa->e;
871.   			rsa->n = NULL;

static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
	UI_METHOD *ui_method, void *callback_data)
	{
	EVP_PKEY *res = NULL;
#ifndef OPENSSL_NO_RSA
        res = hwcrhk_load_privkey(eng, key_id,
                ui_method, callback_data);
#endif
	if (res)
		switch(res->type)
			{
#ifndef OPENSSL_NO_RSA
		case EVP_PKEY_RSA:
			{
			RSA *rsa = NULL;
			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
			rsa = res->pkey.rsa;
			res->pkey.rsa = RSA_new();
			res->pkey.rsa->n = rsa->n;
			res->pkey.rsa->e = rsa->e;
			rsa->n = NULL;
			rsa->e = NULL;
			CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
			RSA_free(rsa);
			}
			break;
#endif
		default:
			HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
				HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
			goto err;
			}
	return res;
 err:
	if (res)
		EVP_PKEY_free(res);
	return NULL;
	}
['static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,\n\tUI_METHOD *ui_method, void *callback_data)\n\t{\n\tEVP_PKEY *res = NULL;\n#ifndef OPENSSL_NO_RSA\n        res = hwcrhk_load_privkey(eng, key_id,\n                ui_method, callback_data);\n#endif\n\tif (res)\n\t\tswitch(res->type)\n\t\t\t{\n#ifndef OPENSSL_NO_RSA\n\t\tcase EVP_PKEY_RSA:\n\t\t\t{\n\t\t\tRSA *rsa = NULL;\n\t\t\tCRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);\n\t\t\trsa = res->pkey.rsa;\n\t\t\tres->pkey.rsa = RSA_new();\n\t\t\tres->pkey.rsa->n = rsa->n;\n\t\t\tres->pkey.rsa->e = rsa->e;\n\t\t\trsa->n = NULL;\n\t\t\trsa->e = NULL;\n\t\t\tCRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);\n\t\t\tRSA_free(rsa);\n\t\t\t}\n\t\t\tbreak;\n#endif\n\t\tdefault:\n\t\t\tHWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,\n\t\t\t\tHWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);\n\t\t\tgoto err;\n\t\t\t}\n\treturn res;\n err:\n\tif (res)\n\t\tEVP_PKEY_free(res);\n\treturn NULL;\n\t}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n\t{\n#ifdef LOCK_DEBUG\n\t\t{\n\t\tchar *rw_text,*operation_text;\n\t\tif (mode & CRYPTO_LOCK)\n\t\t\toperation_text="lock  ";\n\t\telse if (mode & CRYPTO_UNLOCK)\n\t\t\toperation_text="unlock";\n\t\telse\n\t\t\toperation_text="ERROR ";\n\t\tif (mode & CRYPTO_READ)\n\t\t\trw_text="r";\n\t\telse if (mode & CRYPTO_WRITE)\n\t\t\trw_text="w";\n\t\telse\n\t\t\trw_text="ERROR";\n\t\tfprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\\n",\n\t\t\tCRYPTO_thread_id(), rw_text, operation_text,\n\t\t\tCRYPTO_get_lock_name(type), file, line);\n\t\t}\n#endif\n\tif (type < 0)\n\t\t{\n\t\tif (dynlock_lock_callback != NULL)\n\t\t\t{\n\t\t\tstruct CRYPTO_dynlock_value *pointer\n\t\t\t\t= CRYPTO_get_dynlock_value(type);\n\t\t\tOPENSSL_assert(pointer != NULL);\n\t\t\tdynlock_lock_callback(mode, pointer, file, line);\n\t\t\tCRYPTO_destroy_dynlockid(type);\n\t\t\t}\n\t\t}\n\telse\n\t\tif (locking_callback != NULL)\n\t\t\tlocking_callback(mode,type,file,line);\n\t}', 'RSA *RSA_new(void)\n\t{\n\treturn(RSA_new_method(NULL));\n\t}', 'RSA *RSA_new_method(ENGINE *engine)\n\t{\n\tRSA *ret;\n\tret=(RSA *)OPENSSL_malloc(sizeof(RSA));\n\tif (ret == NULL)\n\t\t{\n\t\tRSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);\n\t\treturn NULL;\n\t\t}\n\tret->meth = RSA_get_default_method();\n\tif (engine)\n\t\t{\n\t\tif (!ENGINE_init(engine))\n\t\t\t{\n\t\t\tRSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_ENGINE_LIB);\n\t\t\tOPENSSL_free(ret);\n\t\t\treturn NULL;\n\t\t\t}\n\t\tret->engine = engine;\n\t\t}\n\telse\n\t\tret->engine = ENGINE_get_default_RSA();\n\tif(ret->engine)\n\t\t{\n\t\tret->meth = ENGINE_get_RSA(ret->engine);\n\t\tif(!ret->meth)\n\t\t\t{\n\t\t\tRSAerr(RSA_F_RSA_NEW_METHOD,\n\t\t\t\tERR_R_ENGINE_LIB);\n\t\t\tENGINE_finish(ret->engine);\n\t\t\tOPENSSL_free(ret);\n\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\tret->pad=0;\n\tret->version=0;\n\tret->n=NULL;\n\tret->e=NULL;\n\tret->d=NULL;\n\tret->p=NULL;\n\tret->q=NULL;\n\tret->dmp1=NULL;\n\tret->dmq1=NULL;\n\tret->iqmp=NULL;\n\tret->references=1;\n\tret->_method_mod_n=NULL;\n\tret->_method_mod_p=NULL;\n\tret->_method_mod_q=NULL;\n\tret->blinding=NULL;\n\tret->bignum_data=NULL;\n\tret->flags=ret->meth->flags;\n\tCRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);\n\tif ((ret->meth->init != NULL) && !ret->meth->init(ret))\n\t\t{\n\t\tif (ret->engine)\n\t\t\tENGINE_finish(ret->engine);\n\t\tCRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);\n\t\tOPENSSL_free(ret);\n\t\tret=NULL;\n\t\t}\n\treturn(ret);\n\t}', 'void *CRYPTO_malloc(int num, const char *file, int line)\n\t{\n\tvoid *ret = NULL;\n\textern unsigned char cleanse_ctr;\n\tallow_customize = 0;\n\tif (malloc_debug_func != NULL)\n\t\t{\n\t\tallow_customize_debug = 0;\n\t\tmalloc_debug_func(NULL, num, file, line, 0);\n\t\t}\n\tret = malloc_ex_func(num,file,line);\n#ifdef LEVITTE_DEBUG_MEM\n\tfprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\\n", ret, num);\n#endif\n\tif (malloc_debug_func != NULL)\n\t\tmalloc_debug_func(ret, num, file, line, 1);\n        if(ret && (num > 2048))\n                ((unsigned char *)ret)[0] = cleanse_ctr;\n\treturn ret;\n\t}', 'void ERR_put_error(int lib, int func, int reason, const char *file,\n\t     int line)\n\t{\n\tERR_STATE *es;\n#ifdef _OSD_POSIX\n\tif (strncmp(file,"*POSIX(", sizeof("*POSIX(")-1) == 0) {\n\t\tchar *end;\n\t\tfile += sizeof("*POSIX(")-1;\n\t\tend = &file[strlen(file)-1];\n\t\tif (*end == \')\')\n\t\t\t*end = \'\\0\';\n\t\tif ((end = strrchr(file, \'/\')) != NULL)\n\t\t\tfile = &end[1];\n\t}\n#endif\n\tes=ERR_get_state();\n\tes->top=(es->top+1)%ERR_NUM_ERRORS;\n\tif (es->top == es->bottom)\n\t\tes->bottom=(es->bottom+1)%ERR_NUM_ERRORS;\n\tes->err_buffer[es->top]=ERR_PACK(lib,func,reason);\n\tes->err_file[es->top]=file;\n\tes->err_line[es->top]=line;\n\terr_clear_data(es,es->top);\n\t}']