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


engines/e_chil.c:862:1: start of procedure hwcrhk_load_pubkey()
860.   	}
861.   
862. > static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
863.   	UI_METHOD *ui_method, void *callback_data)
864.   	{

engines/e_chil.c:865:2: 
863.   	UI_METHOD *ui_method, void *callback_data)
864.   	{
865. > 	EVP_PKEY *res = NULL;
866.   
867.   #ifndef OPENSSL_NO_RSA

engines/e_chil.c:868:9: Skipping hwcrhk_load_privkey(): empty list of specs
866.   
867.   #ifndef OPENSSL_NO_RSA
868.           res = hwcrhk_load_privkey(eng, key_id,
               ^
869.                   ui_method, callback_data);
870.   #endif

engines/e_chil.c:872:6: Taking true branch
870.   #endif
871.   
872.   	if (res)
            ^
873.   		switch(res->type)
874.   			{

engines/e_chil.c:873:3: 
871.   
872.   	if (res)
873. > 		switch(res->type)
874.   			{
875.   #ifndef OPENSSL_NO_RSA

engines/e_chil.c:876:3: Switch condition is true. Entering switch case
874.   			{
875.   #ifndef OPENSSL_NO_RSA
876.   		case EVP_PKEY_RSA:
         ^
877.   			{
878.   			RSA *rsa = NULL;

engines/e_chil.c:878:4: 
876.   		case EVP_PKEY_RSA:
877.   			{
878. > 			RSA *rsa = NULL;
879.   
880.   			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);

engines/e_chil.c:880:4: 
878.   			RSA *rsa = NULL;
879.   
880. > 			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
881.   			rsa = res->pkey.rsa;
882.   			res->pkey.rsa = RSA_new();

crypto/cryptlib.c:497:1: start of procedure CRYPTO_lock()
  495.   #endif
  496.   
  497. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  498.   	{
  499.   #ifdef LOCK_DEBUG

crypto/cryptlib.c:524:6: Taking false branch
  522.   		}
  523.   #endif
  524.   	if (type < 0)
              ^
  525.   		{
  526.   		if (dynlock_lock_callback != NULL)

crypto/cryptlib.c:539:7: Taking true branch
  537.   		}
  538.   	else
  539.   		if (locking_callback != NULL)
               ^
  540.   			locking_callback(mode,type,file,line);
  541.   	}

crypto/cryptlib.c:540:4: Skipping __function_pointer__(): unresolved function pointer
  538.   	else
  539.   		if (locking_callback != NULL)
  540.   			locking_callback(mode,type,file,line);
            ^
  541.   	}
  542.   

crypto/cryptlib.c:524:2: 
  522.   		}
  523.   #endif
  524. > 	if (type < 0)
  525.   		{
  526.   		if (dynlock_lock_callback != NULL)

crypto/cryptlib.c:541:2: return from a call to CRYPTO_lock
  539.   		if (locking_callback != NULL)
  540.   			locking_callback(mode,type,file,line);
  541.   	}
          ^
  542.   
  543.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

engines/e_chil.c:881:4: 
879.   
880.   			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
881. > 			rsa = res->pkey.rsa;
882.   			res->pkey.rsa = RSA_new();
883.   			res->pkey.rsa->n = rsa->n;

engines/e_chil.c:882:4: 
880.   			CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
881.   			rsa = res->pkey.rsa;
882. > 			res->pkey.rsa = RSA_new();
883.   			res->pkey.rsa->n = rsa->n;
884.   			res->pkey.rsa->e = rsa->e;

crypto/rsa/rsa_lib.c:74:1: start of procedure RSA_new()
  72.   static const RSA_METHOD *default_RSA_meth=NULL;
  73.   
  74. > RSA *RSA_new(void)
  75.   	{
  76.   	RSA *r=RSA_new_method(NULL);

crypto/rsa/rsa_lib.c:76:2: 
  74.   RSA *RSA_new(void)
  75.   	{
  76. > 	RSA *r=RSA_new_method(NULL);
  77.   
  78.   	return r;

crypto/rsa/rsa_lib.c:128:1: start of procedure RSA_new_method()
    126.   	}
    127.   
    128. > RSA *RSA_new_method(ENGINE *engine)
    129.   	{
    130.   	RSA *ret;

crypto/rsa/rsa_lib.c:132:2: 
    130.   	RSA *ret;
    131.   
    132. > 	ret=(RSA *)OPENSSL_malloc(sizeof(RSA));
    133.   	if (ret == NULL)
    134.   		{

crypto/mem.c:294:1: start of procedure CRYPTO_malloc()
      292.   	}
      293.   
      294. > void *CRYPTO_malloc(int num, const char *file, int line)
      295.   	{
      296.   	void *ret = NULL;

crypto/mem.c:296:2: 
      294.   void *CRYPTO_malloc(int num, const char *file, int line)
      295.   	{
      296. > 	void *ret = NULL;
      297.   
      298.   	if (num <= 0) return NULL;

crypto/mem.c:298:6: Taking false branch
      296.   	void *ret = NULL;
      297.   
      298.   	if (num <= 0) return NULL;
                  ^
      299.   
      300.   	allow_customize = 0;

crypto/mem.c:300:2: 
      298.   	if (num <= 0) return NULL;
      299.   
      300. > 	allow_customize = 0;
      301.   	if (malloc_debug_func != NULL)
      302.   		{

crypto/mem.c:301:6: Taking true branch
      299.   
      300.   	allow_customize = 0;
      301.   	if (malloc_debug_func != NULL)
                  ^
      302.   		{
      303.   		allow_customize_debug = 0;

crypto/mem.c:303:3: 
      301.   	if (malloc_debug_func != NULL)
      302.   		{
      303. > 		allow_customize_debug = 0;
      304.   		malloc_debug_func(NULL, num, file, line, 0);
      305.   		}

crypto/mem.c:304:3: Skipping __function_pointer__(): unresolved function pointer
      302.   		{
      303.   		allow_customize_debug = 0;
      304.   		malloc_debug_func(NULL, num, file, line, 0);
               ^
      305.   		}
      306.   	ret = malloc_ex_func(num,file,line);

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

crypto/mem.c:310:6: Taking true branch
      308.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
      309.   #endif
      310.   	if (malloc_debug_func != NULL)
                  ^
      311.   		malloc_debug_func(ret, num, file, line, 1);
      312.   

crypto/mem.c:311:3: Skipping __function_pointer__(): unresolved function pointer
      309.   #endif
      310.   	if (malloc_debug_func != NULL)
      311.   		malloc_debug_func(ret, num, file, line, 1);
               ^
      312.   
      313.   #ifndef OPENSSL_CPUID_OBJ

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

crypto/mem.c:323:2: 
      321.   #endif
      322.   
      323. > 	return ret;
      324.   	}
      325.   

crypto/mem.c:324:2: return from a call to CRYPTO_malloc
      322.   
      323.   	return ret;
      324.   	}
              ^
      325.   
      326.   void *CRYPTO_realloc(void *str, int num, const char *file, int line)

crypto/rsa/rsa_lib.c:133:6: Taking true branch
    131.   
    132.   	ret=(RSA *)OPENSSL_malloc(sizeof(RSA));
    133.   	if (ret == NULL)
                ^
    134.   		{
    135.   		RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);

crypto/rsa/rsa_lib.c:135:3: 
    133.   	if (ret == NULL)
    134.   		{
    135. > 		RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
    136.   		return NULL;
    137.   		}

crypto/err/err.c:681:1: start of procedure ERR_put_error()
      679.   /********************************************************/
      680.   
      681. > void ERR_put_error(int lib, int func, int reason, const char *file,
      682.   	     int line)
      683.   	{

crypto/err/err.c:705:2: Skipping ERR_get_state(): empty list of specs
      703.   	}
      704.   #endif
      705.   	es=ERR_get_state();
              ^
      706.   
      707.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:707:2: 
      705.   	es=ERR_get_state();
      706.   
      707. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
      708.   	if (es->top == es->bottom)
      709.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:708:6: Taking false branch
      706.   
      707.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
      708.   	if (es->top == es->bottom)
                  ^
      709.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      710.   	es->err_flags[es->top]=0;

crypto/err/err.c:710:2: 
      708.   	if (es->top == es->bottom)
      709.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      710. > 	es->err_flags[es->top]=0;
      711.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      712.   	es->err_file[es->top]=file;

crypto/err/err.c:711:2: 
      709.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      710.   	es->err_flags[es->top]=0;
      711. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      712.   	es->err_file[es->top]=file;
      713.   	es->err_line[es->top]=line;

crypto/err/err.c:712:2: 
      710.   	es->err_flags[es->top]=0;
      711.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      712. > 	es->err_file[es->top]=file;
      713.   	es->err_line[es->top]=line;
      714.   	err_clear_data(es,es->top);

crypto/err/err.c:713:2: 
      711.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      712.   	es->err_file[es->top]=file;
      713. > 	es->err_line[es->top]=line;
      714.   	err_clear_data(es,es->top);
      715.   	}

crypto/err/err.c:714:2: Taking true branch
      712.   	es->err_file[es->top]=file;
      713.   	es->err_line[es->top]=line;
      714.   	err_clear_data(es,es->top);
              ^
      715.   	}
      716.   

crypto/err/err.c:714:2: Taking false branch
      712.   	es->err_file[es->top]=file;
      713.   	es->err_line[es->top]=line;
      714.   	err_clear_data(es,es->top);
              ^
      715.   	}
      716.   

crypto/err/err.c:714:2: Loop condition is false. Leaving loop
      712.   	es->err_file[es->top]=file;
      713.   	es->err_line[es->top]=line;
      714.   	err_clear_data(es,es->top);
              ^
      715.   	}
      716.   

crypto/err/err.c:715:2: return from a call to ERR_put_error
      713.   	es->err_line[es->top]=line;
      714.   	err_clear_data(es,es->top);
      715.   	}
              ^
      716.   
      717.   void ERR_clear_error(void)

crypto/rsa/rsa_lib.c:136:3: 
    134.   		{
    135.   		RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
    136. > 		return NULL;
    137.   		}
    138.   

crypto/rsa/rsa_lib.c:197:2: return from a call to RSA_new_method
    195.   		}
    196.   	return(ret);
    197.   	}
            ^
    198.   
    199.   void RSA_free(RSA *r)

crypto/rsa/rsa_lib.c:78:2: 
  76.   	RSA *r=RSA_new_method(NULL);
  77.   
  78. > 	return r;
  79.   	}
  80.   

crypto/rsa/rsa_lib.c:79:2: return from a call to RSA_new
  77.   
  78.   	return r;
  79.   	}
         ^
  80.   
  81.   void RSA_set_default_method(const RSA_METHOD *meth)

engines/e_chil.c:883:4: 
881.   			rsa = res->pkey.rsa;
882.   			res->pkey.rsa = RSA_new();
883. > 			res->pkey.rsa->n = rsa->n;
884.   			res->pkey.rsa->e = rsa->e;
885.   			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\tCRYPTO_THREADID tid;\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\tCRYPTO_THREADID_set(&tid);\n\t\tfprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\\n",\n\t\t\tCRYPTO_THREADID_hash(&tid), 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\tRSA *r=RSA_new_method(NULL);\n\treturn r;\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#ifndef OPENSSL_NO_ENGINE\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#endif\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->mt_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#ifndef OPENSSL_NO_ENGINE\n\t\tif (ret->engine)\n\t\t\tENGINE_finish(ret->engine);\n#endif\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\tif (num <= 0) return NULL;\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#ifndef OPENSSL_CPUID_OBJ\n        if(ret && (num > 2048))\n\t{\textern unsigned char cleanse_ctr;\n                ((unsigned char *)ret)[0] = cleanse_ctr;\n\t}\n#endif\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_flags[es->top]=0;\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}']