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


engines/e_4758cca.c:475:1: start of procedure ibm_4758_load_pubkey()
473.   	}
474.   
475. > static EVP_PKEY *ibm_4758_load_pubkey(ENGINE* e, const char* key_id,
476.   			UI_METHOD *ui_method, void *callback_data)
477.   	{

engines/e_4758cca.c:478:2: 
476.   			UI_METHOD *ui_method, void *callback_data)
477.   	{
478. > 	RSA *rtmp = NULL;
479.   	EVP_PKEY *res = NULL;
480.   	unsigned char* keyToken = NULL;

engines/e_4758cca.c:479:2: 
477.   	{
478.   	RSA *rtmp = NULL;
479. > 	EVP_PKEY *res = NULL;
480.   	unsigned char* keyToken = NULL;
481.   	long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;

engines/e_4758cca.c:480:2: 
478.   	RSA *rtmp = NULL;
479.   	EVP_PKEY *res = NULL;
480. > 	unsigned char* keyToken = NULL;
481.   	long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
482.   	long returnCode;

engines/e_4758cca.c:481:2: 
479.   	EVP_PKEY *res = NULL;
480.   	unsigned char* keyToken = NULL;
481. > 	long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
482.   	long returnCode;
483.   	long reasonCode;

engines/e_4758cca.c:484:2: 
482.   	long returnCode;
483.   	long reasonCode;
484. > 	long exitDataLength = 0;
485.   	long ruleArrayLength = 0;
486.   	unsigned char exitData[8];

engines/e_4758cca.c:485:2: 
483.   	long reasonCode;
484.   	long exitDataLength = 0;
485. > 	long ruleArrayLength = 0;
486.   	unsigned char exitData[8];
487.   	unsigned char ruleArray[8];

engines/e_4758cca.c:489:2: 
487.   	unsigned char ruleArray[8];
488.   	unsigned char keyLabel[64];
489. > 	unsigned long keyLabelLength = strlen(key_id);
490.   	unsigned char modulus[512];
491.   	long modulusFieldLength = sizeof(modulus);

engines/e_4758cca.c:491:2: 
489.   	unsigned long keyLabelLength = strlen(key_id);
490.   	unsigned char modulus[512];
491. > 	long modulusFieldLength = sizeof(modulus);
492.   	long modulusLength = 0;
493.   	unsigned char exponent[512];

engines/e_4758cca.c:492:2: 
490.   	unsigned char modulus[512];
491.   	long modulusFieldLength = sizeof(modulus);
492. > 	long modulusLength = 0;
493.   	unsigned char exponent[512];
494.   	long exponentLength = sizeof(exponent);

engines/e_4758cca.c:494:2: 
492.   	long modulusLength = 0;
493.   	unsigned char exponent[512];
494. > 	long exponentLength = sizeof(exponent);
495.   
496.   	if (keyLabelLength > sizeof(keyLabel))

engines/e_4758cca.c:496:6: Taking false branch
494.   	long exponentLength = sizeof(exponent);
495.   
496.   	if (keyLabelLength > sizeof(keyLabel))
            ^
497.   		{
498.   		CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,

engines/e_4758cca.c:503:2: 
501.   		}
502.   
503. > 	memset(keyLabel,' ', sizeof(keyLabel));
504.   	memcpy(keyLabel, key_id, keyLabelLength);
505.   

engines/e_4758cca.c:504:2: 
502.   
503.   	memset(keyLabel,' ', sizeof(keyLabel));
504. > 	memcpy(keyLabel, key_id, keyLabelLength);
505.   
506.   	keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));

engines/e_4758cca.c:506:2: 
504.   	memcpy(keyLabel, key_id, keyLabelLength);
505.   
506. > 	keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
507.   	if (!keyToken)
508.   		{

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

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

crypto/mem.c:296:6: Taking false branch
  294.   	extern unsigned char cleanse_ctr;
  295.   
  296.   	if (num <= 0) return NULL;
              ^
  297.   
  298.   	allow_customize = 0;

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

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

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

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

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

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

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

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

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

crypto/mem.c:315:17: 
  313.            * this for >2Kb so the overhead doesn't bother us. */
  314.           if(ret && (num > 2048))
  315. >                 ((unsigned char *)ret)[0] = cleanse_ctr;
  316.   
  317.   	return ret;

crypto/mem.c:317:2: 
  315.                   ((unsigned char *)ret)[0] = cleanse_ctr;
  316.   
  317. > 	return ret;
  318.   	}
  319.   

crypto/mem.c:318:2: return from a call to CRYPTO_malloc
  316.   
  317.   	return ret;
  318.   	}
          ^
  319.   
  320.   void *CRYPTO_realloc(void *str, int num, const char *file, int line)

engines/e_4758cca.c:507:7: Taking false branch
505.   
506.   	keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
507.   	if (!keyToken)
             ^
508.   		{
509.   		CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,

engines/e_4758cca.c:514:2: Skipping __function_pointer__(): unresolved function pointer
512.   		}
513.   
514.   	keyRecordRead(&returnCode, &reasonCode, &exitDataLength, exitData,
        ^
515.   		&ruleArrayLength, ruleArray, keyLabel, &keyTokenLength,
516.   		keyToken+sizeof(long));

engines/e_4758cca.c:518:6: Taking false branch
516.   		keyToken+sizeof(long));
517.   
518.   	if (returnCode)
            ^
519.   		{
520.   		CCA4758err(CCA4758_F_IBM_4758_LOAD_PUBKEY,

engines/e_4758cca.c:525:7: 
523.   		}
524.   
525. > 	if (!getModulusAndExponent(keyToken+sizeof(long), &exponentLength,
526.   			exponent, &modulusLength, &modulusFieldLength, modulus))
527.   		{

engines/e_4758cca.c:857:1: start of procedure getModulusAndExponent()
  855.   	}
  856.   
  857. > static int getModulusAndExponent(const unsigned char*token, long *exponentLength,
  858.   		unsigned char *exponent, long *modulusLength, long *modulusFieldLength,
  859.   		unsigned char *modulus)

engines/e_4758cca.c:863:6: Taking false branch
  861.   	unsigned long len;
  862.   
  863.   	if (*token++ != (char)0x1E) /* internal PKA token? */
              ^
  864.   		return 0;
  865.   

engines/e_4758cca.c:866:6: Taking false branch
  864.   		return 0;
  865.   
  866.   	if (*token++) /* token version must be zero */
              ^
  867.   		return 0;
  868.   

engines/e_4758cca.c:869:2: 
  867.   		return 0;
  868.   
  869. > 	len = *token++;
  870.   	len = len << 8;
  871.   	len |= (unsigned char)*token++;

engines/e_4758cca.c:870:2: 
  868.   
  869.   	len = *token++;
  870. > 	len = len << 8;
  871.   	len |= (unsigned char)*token++;
  872.   

engines/e_4758cca.c:871:2: 
  869.   	len = *token++;
  870.   	len = len << 8;
  871. > 	len |= (unsigned char)*token++;
  872.   
  873.   	token += 4; /* skip reserved bytes */

engines/e_4758cca.c:873:2: 
  871.   	len |= (unsigned char)*token++;
  872.   
  873. > 	token += 4; /* skip reserved bytes */
  874.   
  875.   	if (*token++ == (char)0x04)

engines/e_4758cca.c:875:6: Taking true branch
  873.   	token += 4; /* skip reserved bytes */
  874.   
  875.   	if (*token++ == (char)0x04)
              ^
  876.   		{
  877.   		if (*token++) /* token version must be zero */

engines/e_4758cca.c:877:7: Taking false branch
  875.   	if (*token++ == (char)0x04)
  876.   		{
  877.   		if (*token++) /* token version must be zero */
               ^
  878.   			return 0;
  879.   

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

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

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

engines/e_4758cca.c:884:3: 
  882.   		len |= (unsigned char)*token++;
  883.   
  884. > 		token+=2; /* skip reserved section */
  885.   
  886.   		len = *token++;

engines/e_4758cca.c:886:3: 
  884.   		token+=2; /* skip reserved section */
  885.   
  886. > 		len = *token++;
  887.   		len = len << 8;
  888.   		len |= (unsigned char)*token++;

engines/e_4758cca.c:887:3: 
  885.   
  886.   		len = *token++;
  887. > 		len = len << 8;
  888.   		len |= (unsigned char)*token++;
  889.   

engines/e_4758cca.c:888:3: 
  886.   		len = *token++;
  887.   		len = len << 8;
  888. > 		len |= (unsigned char)*token++;
  889.   
  890.   		*exponentLength = len;

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

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

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

engines/e_4758cca.c:894:3: 
  892.   		len = *token++;
  893.   		len = len << 8;
  894. > 		len |= (unsigned char)*token++;
  895.   
  896.   		*modulusLength = len;

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

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

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

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

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

engines/e_4758cca.c:904:3: 
  902.   		*modulusFieldLength = len;
  903.   
  904. > 		memcpy(exponent, token, *exponentLength);
  905.   		token+= *exponentLength;
  906.   

engines/e_4758cca.c:905:3: 
  903.   
  904.   		memcpy(exponent, token, *exponentLength);
  905. > 		token+= *exponentLength;
  906.   
  907.   		memcpy(modulus, token, *modulusFieldLength);

engines/e_4758cca.c:907:3: 
  905.   		token+= *exponentLength;
  906.   
  907. > 		memcpy(modulus, token, *modulusFieldLength);
  908.   		return 1;
  909.   		}

engines/e_4758cca.c:908:3: 
  906.   
  907.   		memcpy(modulus, token, *modulusFieldLength);
  908. > 		return 1;
  909.   		}
  910.   	return 0;

engines/e_4758cca.c:911:2: return from a call to getModulusAndExponent
  909.   		}
  910.   	return 0;
  911.   	}
          ^
  912.   
  913.   #endif /* OPENSSL_NO_RSA */

engines/e_4758cca.c:525:7: Taking false branch
523.   		}
524.   
525.   	if (!getModulusAndExponent(keyToken+sizeof(long), &exponentLength,
             ^
526.   			exponent, &modulusLength, &modulusFieldLength, modulus))
527.   		{

engines/e_4758cca.c:533:2: 
531.   		}
532.   
533. > 	(*(long*)keyToken) = keyTokenLength;
534.   	rtmp = RSA_new_method(e);
535.   	RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);

engines/e_4758cca.c:534:2: 
532.   
533.   	(*(long*)keyToken) = keyTokenLength;
534. > 	rtmp = RSA_new_method(e);
535.   	RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
536.   	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:291:1: start of procedure CRYPTO_malloc()
    289.   	}
    290.   
    291. > void *CRYPTO_malloc(int num, const char *file, int line)
    292.   	{
    293.   	void *ret = NULL;

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

crypto/mem.c:296:6: Taking false branch
    294.   	extern unsigned char cleanse_ctr;
    295.   
    296.   	if (num <= 0) return NULL;
                ^
    297.   
    298.   	allow_customize = 0;

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

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

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

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

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

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

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

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

crypto/mem.c:317:2: 
    315.                   ((unsigned char *)ret)[0] = cleanse_ctr;
    316.   
    317. > 	return ret;
    318.   	}
    319.   

crypto/mem.c:318:2: return from a call to CRYPTO_malloc
    316.   
    317.   	return ret;
    318.   	}
            ^
    319.   
    320.   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:666:1: start of procedure ERR_put_error()
    664.   /********************************************************/
    665.   
    666. > void ERR_put_error(int lib, int func, int reason, const char *file,
    667.   	     int line)
    668.   	{

crypto/err/err.c:690:2: Skipping ERR_get_state(): empty list of specs
    688.   	}
    689.   #endif
    690.   	es=ERR_get_state();
            ^
    691.   
    692.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:692:2: 
    690.   	es=ERR_get_state();
    691.   
    692. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
    693.   	if (es->top == es->bottom)
    694.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:693:6: Taking false branch
    691.   
    692.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
    693.   	if (es->top == es->bottom)
                ^
    694.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    695.   	es->err_flags[es->top]=0;

crypto/err/err.c:695:2: 
    693.   	if (es->top == es->bottom)
    694.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    695. > 	es->err_flags[es->top]=0;
    696.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    697.   	es->err_file[es->top]=file;

crypto/err/err.c:696:2: 
    694.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    695.   	es->err_flags[es->top]=0;
    696. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    697.   	es->err_file[es->top]=file;
    698.   	es->err_line[es->top]=line;

crypto/err/err.c:697:2: 
    695.   	es->err_flags[es->top]=0;
    696.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    697. > 	es->err_file[es->top]=file;
    698.   	es->err_line[es->top]=line;
    699.   	err_clear_data(es,es->top);

crypto/err/err.c:698:2: 
    696.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    697.   	es->err_file[es->top]=file;
    698. > 	es->err_line[es->top]=line;
    699.   	err_clear_data(es,es->top);
    700.   	}

crypto/err/err.c:699:2: Taking true branch
    697.   	es->err_file[es->top]=file;
    698.   	es->err_line[es->top]=line;
    699.   	err_clear_data(es,es->top);
            ^
    700.   	}
    701.   

crypto/err/err.c:699:2: Taking false branch
    697.   	es->err_file[es->top]=file;
    698.   	es->err_line[es->top]=line;
    699.   	err_clear_data(es,es->top);
            ^
    700.   	}
    701.   

crypto/err/err.c:699:2: Loop condition is false. Leaving loop
    697.   	es->err_file[es->top]=file;
    698.   	es->err_line[es->top]=line;
    699.   	err_clear_data(es,es->top);
            ^
    700.   	}
    701.   

crypto/err/err.c:700:2: return from a call to ERR_put_error
    698.   	es->err_line[es->top]=line;
    699.   	err_clear_data(es,es->top);
    700.   	}
            ^
    701.   
    702.   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:535:2: 
533.   	(*(long*)keyToken) = keyTokenLength;
534.   	rtmp = RSA_new_method(e);
535. > 	RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
536.   	rtmp->e = BN_bin2bn(exponent, exponentLength, NULL);
537.   	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);
	if (res)
		EVP_PKEY_free(res);
	if (rtmp)
		RSA_free(rtmp);
	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\tif (res)\n\t\tEVP_PKEY_free(res);\n\tif (rtmp)\n\t\tRSA_free(rtmp);\n\treturn NULL;\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\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        if(ret && (num > 2048))\n                ((unsigned char *)ret)[0] = cleanse_ctr;\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}']