engines/e_4758cca.c:548: error: NULL_DEREFERENCE
  pointer `rtmp` last assigned on line 547 could be null and is dereferenced by call to `RSA_set_ex_data()` at line 548, column 2.
Showing all 99 steps of the trace


engines/e_4758cca.c:488:1: start of procedure ibm_4758_load_pubkey()
486.   	}
487.   
488. > static EVP_PKEY *ibm_4758_load_pubkey(ENGINE* e, const char* key_id,
489.   			UI_METHOD *ui_method, void *callback_data)
490.   	{

engines/e_4758cca.c:491:2: 
489.   			UI_METHOD *ui_method, void *callback_data)
490.   	{
491. > 	RSA *rtmp = NULL;
492.   	EVP_PKEY *res = NULL;
493.   	unsigned char* keyToken = NULL;

engines/e_4758cca.c:492:2: 
490.   	{
491.   	RSA *rtmp = NULL;
492. > 	EVP_PKEY *res = NULL;
493.   	unsigned char* keyToken = NULL;
494.   	long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;

engines/e_4758cca.c:493:2: 
491.   	RSA *rtmp = NULL;
492.   	EVP_PKEY *res = NULL;
493. > 	unsigned char* keyToken = NULL;
494.   	long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
495.   	long returnCode;

engines/e_4758cca.c:494:2: 
492.   	EVP_PKEY *res = NULL;
493.   	unsigned char* keyToken = NULL;
494. > 	long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
495.   	long returnCode;
496.   	long reasonCode;

engines/e_4758cca.c:497:2: 
495.   	long returnCode;
496.   	long reasonCode;
497. > 	long exitDataLength = 0;
498.   	long ruleArrayLength = 0;
499.   	unsigned char exitData[8];

engines/e_4758cca.c:498:2: 
496.   	long reasonCode;
497.   	long exitDataLength = 0;
498. > 	long ruleArrayLength = 0;
499.   	unsigned char exitData[8];
500.   	unsigned char ruleArray[8];

engines/e_4758cca.c:502:2: 
500.   	unsigned char ruleArray[8];
501.   	unsigned char keyLabel[64];
502. > 	unsigned long keyLabelLength = strlen(key_id);
503.   	unsigned char modulus[512];
504.   	long modulusFieldLength = sizeof(modulus);

engines/e_4758cca.c:504:2: 
502.   	unsigned long keyLabelLength = strlen(key_id);
503.   	unsigned char modulus[512];
504. > 	long modulusFieldLength = sizeof(modulus);
505.   	long modulusLength = 0;
506.   	unsigned char exponent[512];

engines/e_4758cca.c:505:2: 
503.   	unsigned char modulus[512];
504.   	long modulusFieldLength = sizeof(modulus);
505. > 	long modulusLength = 0;
506.   	unsigned char exponent[512];
507.   	long exponentLength = sizeof(exponent);

engines/e_4758cca.c:507:2: 
505.   	long modulusLength = 0;
506.   	unsigned char exponent[512];
507. > 	long exponentLength = sizeof(exponent);
508.   
509.   	if (keyLabelLength > sizeof(keyLabel))

engines/e_4758cca.c:509:6: Taking false branch
507.   	long exponentLength = sizeof(exponent);
508.   
509.   	if (keyLabelLength > sizeof(keyLabel))
            ^
510.   		{
511.   		CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,

engines/e_4758cca.c:516:2: 
514.   		}
515.   
516. > 	memset(keyLabel,' ', sizeof(keyLabel));
517.   	memcpy(keyLabel, key_id, keyLabelLength);
518.   

engines/e_4758cca.c:517:2: 
515.   
516.   	memset(keyLabel,' ', sizeof(keyLabel));
517. > 	memcpy(keyLabel, key_id, keyLabelLength);
518.   
519.   	keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));

engines/e_4758cca.c:519:2: 
517.   	memcpy(keyLabel, key_id, keyLabelLength);
518.   
519. > 	keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
520.   	if (!keyToken)
521.   		{

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 true 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:317:20: Taking true 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:319:17: 
  317.           if(ret && (num > 2048))
  318.   	{	extern unsigned char cleanse_ctr;
  319. >                 ((unsigned char *)ret)[0] = cleanse_ctr;
  320.   	}
  321.   #endif

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)

engines/e_4758cca.c:520:7: Taking false branch
518.   
519.   	keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
520.   	if (!keyToken)
             ^
521.   		{
522.   		CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,

engines/e_4758cca.c:527:2: Skipping __function_pointer__(): unresolved function pointer
525.   		}
526.   
527.   	keyRecordRead(&returnCode, &reasonCode, &exitDataLength, exitData,
        ^
528.   		&ruleArrayLength, ruleArray, keyLabel, &keyTokenLength,
529.   		keyToken+sizeof(long));

engines/e_4758cca.c:531:6: Taking false branch
529.   		keyToken+sizeof(long));
530.   
531.   	if (returnCode)
            ^
532.   		{
533.   		CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,

engines/e_4758cca.c:538:7: 
536.   		}
537.   
538. > 	if (!getModulusAndExponent(keyToken+sizeof(long), &exponentLength,
539.   			exponent, &modulusLength, &modulusFieldLength, modulus))
540.   		{

engines/e_4758cca.c:867:1: start of procedure getModulusAndExponent()
  865.   	}
  866.   
  867. > static int getModulusAndExponent(const unsigned char*token, long *exponentLength,
  868.   		unsigned char *exponent, long *modulusLength, long *modulusFieldLength,
  869.   		unsigned char *modulus)

engines/e_4758cca.c:873:6: Taking false branch
  871.   	unsigned long len;
  872.   
  873.   	if (*token++ != (char)0x1E) /* internal PKA token? */
              ^
  874.   		return 0;
  875.   

engines/e_4758cca.c:876:6: Taking false branch
  874.   		return 0;
  875.   
  876.   	if (*token++) /* token version must be zero */
              ^
  877.   		return 0;
  878.   

engines/e_4758cca.c:879:2: 
  877.   		return 0;
  878.   
  879. > 	len = *token++;
  880.   	len = len << 8;
  881.   	len |= (unsigned char)*token++;

engines/e_4758cca.c:880:2: 
  878.   
  879.   	len = *token++;
  880. > 	len = len << 8;
  881.   	len |= (unsigned char)*token++;
  882.   

engines/e_4758cca.c:881:2: 
  879.   	len = *token++;
  880.   	len = len << 8;
  881. > 	len |= (unsigned char)*token++;
  882.   
  883.   	token += 4; /* skip reserved bytes */

engines/e_4758cca.c:883:2: 
  881.   	len |= (unsigned char)*token++;
  882.   
  883. > 	token += 4; /* skip reserved bytes */
  884.   
  885.   	if (*token++ == (char)0x04)

engines/e_4758cca.c:885:6: Taking true branch
  883.   	token += 4; /* skip reserved bytes */
  884.   
  885.   	if (*token++ == (char)0x04)
              ^
  886.   		{
  887.   		if (*token++) /* token version must be zero */

engines/e_4758cca.c:887:7: Taking false branch
  885.   	if (*token++ == (char)0x04)
  886.   		{
  887.   		if (*token++) /* token version must be zero */
               ^
  888.   			return 0;
  889.   

engines/e_4758cca.c:890:3: 
  888.   			return 0;
  889.   
  890. > 		len = *token++;
  891.   		len = len << 8;
  892.   		len |= (unsigned char)*token++;

engines/e_4758cca.c:891:3: 
  889.   
  890.   		len = *token++;
  891. > 		len = len << 8;
  892.   		len |= (unsigned char)*token++;
  893.   

engines/e_4758cca.c:892:3: 
  890.   		len = *token++;
  891.   		len = len << 8;
  892. > 		len |= (unsigned char)*token++;
  893.   
  894.   		token+=2; /* skip reserved section */

engines/e_4758cca.c:894:3: 
  892.   		len |= (unsigned char)*token++;
  893.   
  894. > 		token+=2; /* skip reserved section */
  895.   
  896.   		len = *token++;

engines/e_4758cca.c:896:3: 
  894.   		token+=2; /* skip reserved section */
  895.   
  896. > 		len = *token++;
  897.   		len = len << 8;
  898.   		len |= (unsigned char)*token++;

engines/e_4758cca.c:897:3: 
  895.   
  896.   		len = *token++;
  897. > 		len = len << 8;
  898.   		len |= (unsigned char)*token++;
  899.   

engines/e_4758cca.c:898:3: 
  896.   		len = *token++;
  897.   		len = len << 8;
  898. > 		len |= (unsigned char)*token++;
  899.   
  900.   		*exponentLength = len;

engines/e_4758cca.c:900:3: 
  898.   		len |= (unsigned char)*token++;
  899.   
  900. > 		*exponentLength = len;
  901.   
  902.   		len = *token++;

engines/e_4758cca.c:902:3: 
  900.   		*exponentLength = len;
  901.   
  902. > 		len = *token++;
  903.   		len = len << 8;
  904.   		len |= (unsigned char)*token++;

engines/e_4758cca.c:903:3: 
  901.   
  902.   		len = *token++;
  903. > 		len = len << 8;
  904.   		len |= (unsigned char)*token++;
  905.   

engines/e_4758cca.c:904:3: 
  902.   		len = *token++;
  903.   		len = len << 8;
  904. > 		len |= (unsigned char)*token++;
  905.   
  906.   		*modulusLength = len;

engines/e_4758cca.c:906:3: 
  904.   		len |= (unsigned char)*token++;
  905.   
  906. > 		*modulusLength = len;
  907.   
  908.   		len = *token++;

engines/e_4758cca.c:908:3: 
  906.   		*modulusLength = len;
  907.   
  908. > 		len = *token++;
  909.   		len = len << 8;
  910.   		len |= (unsigned char)*token++;

engines/e_4758cca.c:909:3: 
  907.   
  908.   		len = *token++;
  909. > 		len = len << 8;
  910.   		len |= (unsigned char)*token++;
  911.   

engines/e_4758cca.c:910:3: 
  908.   		len = *token++;
  909.   		len = len << 8;
  910. > 		len |= (unsigned char)*token++;
  911.   
  912.   		*modulusFieldLength = len;

engines/e_4758cca.c:912:3: 
  910.   		len |= (unsigned char)*token++;
  911.   
  912. > 		*modulusFieldLength = len;
  913.   
  914.   		memcpy(exponent, token, *exponentLength);

engines/e_4758cca.c:914:3: 
  912.   		*modulusFieldLength = len;
  913.   
  914. > 		memcpy(exponent, token, *exponentLength);
  915.   		token+= *exponentLength;
  916.   

engines/e_4758cca.c:915:3: 
  913.   
  914.   		memcpy(exponent, token, *exponentLength);
  915. > 		token+= *exponentLength;
  916.   
  917.   		memcpy(modulus, token, *modulusFieldLength);

engines/e_4758cca.c:917:3: 
  915.   		token+= *exponentLength;
  916.   
  917. > 		memcpy(modulus, token, *modulusFieldLength);
  918.   		return 1;
  919.   		}

engines/e_4758cca.c:918:3: 
  916.   
  917.   		memcpy(modulus, token, *modulusFieldLength);
  918. > 		return 1;
  919.   		}
  920.   	return 0;

engines/e_4758cca.c:921:2: return from a call to getModulusAndExponent
  919.   		}
  920.   	return 0;
  921.   	}
          ^
  922.   
  923.   #endif /* OPENSSL_NO_RSA */

engines/e_4758cca.c:538:7: Taking false branch
536.   		}
537.   
538.   	if (!getModulusAndExponent(keyToken+sizeof(long), &exponentLength,
             ^
539.   			exponent, &modulusLength, &modulusFieldLength, modulus))
540.   		{

engines/e_4758cca.c:546:2: 
544.   		}
545.   
546. > 	(*(long*)keyToken) = keyTokenLength;
547.   	rtmp = RSA_new_method(e);
548.   	RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);

engines/e_4758cca.c:547:2: 
545.   
546.   	(*(long*)keyToken) = keyTokenLength;
547. > 	rtmp = RSA_new_method(e);
548.   	RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
549.   	rtmp->e = BN_bin2bn(exponent, exponentLength, NULL);

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:706:1: start of procedure ERR_put_error()
    704.   /********************************************************/
    705.   
    706. > void ERR_put_error(int lib, int func, int reason, const char *file,
    707.   	     int line)
    708.   	{

crypto/err/err.c:730:2: Skipping ERR_get_state(): empty list of specs
    728.   	}
    729.   #endif
    730.   	es=ERR_get_state();
            ^
    731.   
    732.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:732:2: 
    730.   	es=ERR_get_state();
    731.   
    732. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
    733.   	if (es->top == es->bottom)
    734.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:733:6: Taking false branch
    731.   
    732.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
    733.   	if (es->top == es->bottom)
                ^
    734.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    735.   	es->err_flags[es->top]=0;

crypto/err/err.c:735:2: 
    733.   	if (es->top == es->bottom)
    734.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    735. > 	es->err_flags[es->top]=0;
    736.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    737.   	es->err_file[es->top]=file;

crypto/err/err.c:736:2: 
    734.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    735.   	es->err_flags[es->top]=0;
    736. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    737.   	es->err_file[es->top]=file;
    738.   	es->err_line[es->top]=line;

crypto/err/err.c:737:2: 
    735.   	es->err_flags[es->top]=0;
    736.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    737. > 	es->err_file[es->top]=file;
    738.   	es->err_line[es->top]=line;
    739.   	err_clear_data(es,es->top);

crypto/err/err.c:738:2: 
    736.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    737.   	es->err_file[es->top]=file;
    738. > 	es->err_line[es->top]=line;
    739.   	err_clear_data(es,es->top);
    740.   	}

crypto/err/err.c:739:2: Taking true branch
    737.   	es->err_file[es->top]=file;
    738.   	es->err_line[es->top]=line;
    739.   	err_clear_data(es,es->top);
            ^
    740.   	}
    741.   

crypto/err/err.c:739:2: Taking false branch
    737.   	es->err_file[es->top]=file;
    738.   	es->err_line[es->top]=line;
    739.   	err_clear_data(es,es->top);
            ^
    740.   	}
    741.   

crypto/err/err.c:739:2: Loop condition is false. Leaving loop
    737.   	es->err_file[es->top]=file;
    738.   	es->err_line[es->top]=line;
    739.   	err_clear_data(es,es->top);
            ^
    740.   	}
    741.   

crypto/err/err.c:740:2: return from a call to ERR_put_error
    738.   	es->err_line[es->top]=line;
    739.   	err_clear_data(es,es->top);
    740.   	}
            ^
    741.   
    742.   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)

engines/e_4758cca.c:548:2: 
546.   	(*(long*)keyToken) = keyTokenLength;
547.   	rtmp = RSA_new_method(e);
548. > 	RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
549.   	rtmp->e = BN_bin2bn(exponent, exponentLength, NULL);
550.   	rtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL);

static EVP_PKEY *ibm_4758_load_pubkey(ENGINE* e, const char* key_id,
			UI_METHOD *ui_method, void *callback_data)
	{
	RSA *rtmp = NULL;
	EVP_PKEY *res = NULL;
	unsigned char* keyToken = NULL;
	long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
	long returnCode;
	long reasonCode;
	long exitDataLength = 0;
	long ruleArrayLength = 0;
	unsigned char exitData[8];
	unsigned char ruleArray[8];
	unsigned char keyLabel[64];
	unsigned long keyLabelLength = strlen(key_id);
	unsigned char modulus[512];
	long modulusFieldLength = sizeof(modulus);
	long modulusLength = 0;
	unsigned char exponent[512];
	long exponentLength = sizeof(exponent);
	if (keyLabelLength > sizeof(keyLabel))
		{
		CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,
			CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
		return NULL;
		}
	memset(keyLabel,' ', sizeof(keyLabel));
	memcpy(keyLabel, key_id, keyLabelLength);
	keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
	if (!keyToken)
		{
		CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,
				ERR_R_MALLOC_FAILURE);
		goto err;
		}
	keyRecordRead(&returnCode, &reasonCode, &exitDataLength, exitData,
		&ruleArrayLength, ruleArray, keyLabel, &keyTokenLength,
		keyToken+sizeof(long));
	if (returnCode)
		{
		CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,
				ERR_R_MALLOC_FAILURE);
		goto err;
		}
	if (!getModulusAndExponent(keyToken+sizeof(long), &exponentLength,
			exponent, &modulusLength, &modulusFieldLength, modulus))
		{
		CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,
			CCA4758_R_FAILED_LOADING_PUBLIC_KEY);
		goto err;
		}
	(*(long*)keyToken) = keyTokenLength;
	rtmp = RSA_new_method(e);
	RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
	rtmp->e = BN_bin2bn(exponent, exponentLength, NULL);
	rtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL);
	rtmp->flags |= RSA_FLAG_EXT_PKEY;
	res = EVP_PKEY_new();
	EVP_PKEY_assign_RSA(res, rtmp);
	return res;
err:
	if (keyToken)
		OPENSSL_free(keyToken);
	return NULL;
	}
["static EVP_PKEY *ibm_4758_load_pubkey(ENGINE* e, const char* key_id,\n\t\t\tUI_METHOD *ui_method, void *callback_data)\n\t{\n\tRSA *rtmp = NULL;\n\tEVP_PKEY *res = NULL;\n\tunsigned char* keyToken = NULL;\n\tlong keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;\n\tlong returnCode;\n\tlong reasonCode;\n\tlong exitDataLength = 0;\n\tlong ruleArrayLength = 0;\n\tunsigned char exitData[8];\n\tunsigned char ruleArray[8];\n\tunsigned char keyLabel[64];\n\tunsigned long keyLabelLength = strlen(key_id);\n\tunsigned char modulus[512];\n\tlong modulusFieldLength = sizeof(modulus);\n\tlong modulusLength = 0;\n\tunsigned char exponent[512];\n\tlong exponentLength = sizeof(exponent);\n\tif (keyLabelLength > sizeof(keyLabel))\n\t\t{\n\t\tCCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,\n\t\t\tCCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);\n\t\treturn NULL;\n\t\t}\n\tmemset(keyLabel,' ', sizeof(keyLabel));\n\tmemcpy(keyLabel, key_id, keyLabelLength);\n\tkeyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));\n\tif (!keyToken)\n\t\t{\n\t\tCCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,\n\t\t\t\tERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\tkeyRecordRead(&returnCode, &reasonCode, &exitDataLength, exitData,\n\t\t&ruleArrayLength, ruleArray, keyLabel, &keyTokenLength,\n\t\tkeyToken+sizeof(long));\n\tif (returnCode)\n\t\t{\n\t\tCCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,\n\t\t\t\tERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\tif (!getModulusAndExponent(keyToken+sizeof(long), &exponentLength,\n\t\t\texponent, &modulusLength, &modulusFieldLength, modulus))\n\t\t{\n\t\tCCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,\n\t\t\tCCA4758_R_FAILED_LOADING_PUBLIC_KEY);\n\t\tgoto err;\n\t\t}\n\t(*(long*)keyToken) = keyTokenLength;\n\trtmp = RSA_new_method(e);\n\tRSA_set_ex_data(rtmp, hndidx, (char *)keyToken);\n\trtmp->e = BN_bin2bn(exponent, exponentLength, NULL);\n\trtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL);\n\trtmp->flags |= RSA_FLAG_EXT_PKEY;\n\tres = EVP_PKEY_new();\n\tEVP_PKEY_assign_RSA(res, rtmp);\n\treturn res;\nerr:\n\tif (keyToken)\n\t\tOPENSSL_free(keyToken);\n\treturn NULL;\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}', 'static int getModulusAndExponent(const unsigned char*token, long *exponentLength,\n\t\tunsigned char *exponent, long *modulusLength, long *modulusFieldLength,\n\t\tunsigned char *modulus)\n\t{\n\tunsigned long len;\n\tif (*token++ != (char)0x1E)\n\t\treturn 0;\n\tif (*token++)\n\t\treturn 0;\n\tlen = *token++;\n\tlen = len << 8;\n\tlen |= (unsigned char)*token++;\n\ttoken += 4;\n\tif (*token++ == (char)0x04)\n\t\t{\n\t\tif (*token++)\n\t\t\treturn 0;\n\t\tlen = *token++;\n\t\tlen = len << 8;\n\t\tlen |= (unsigned char)*token++;\n\t\ttoken+=2;\n\t\tlen = *token++;\n\t\tlen = len << 8;\n\t\tlen |= (unsigned char)*token++;\n\t\t*exponentLength = len;\n\t\tlen = *token++;\n\t\tlen = len << 8;\n\t\tlen |= (unsigned char)*token++;\n\t\t*modulusLength = len;\n\t\tlen = *token++;\n\t\tlen = len << 8;\n\t\tlen |= (unsigned char)*token++;\n\t\t*modulusFieldLength = len;\n\t\tmemcpy(exponent, token, *exponentLength);\n\t\ttoken+= *exponentLength;\n\t\tmemcpy(modulus, token, *modulusFieldLength);\n\t\treturn 1;\n\t\t}\n\treturn 0;\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 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}']