engines/e_4758_cca.c:596: error: NULL_DEREFERENCE
  pointer `keyToken` last assigned on line 594 could be null and is dereferenced at line 596, column 19.
Showing all 37 steps of the trace


engines/e_4758_cca.c:580:1: start of procedure cca_rsa_priv_dec()
578.   	}
579.   
580. > static int cca_rsa_priv_dec(int flen, const unsigned char *from,
581.   			unsigned char *to, RSA *rsa,int padding)
582.   	{

engines/e_4758_cca.c:585:2: 
583.   	long returnCode;
584.   	long reasonCode;
585. > 	long lflen = flen;
586.   	long exitDataLength = 0;
587.   	unsigned char exitData[8];

engines/e_4758_cca.c:586:2: 
584.   	long reasonCode;
585.   	long lflen = flen;
586. > 	long exitDataLength = 0;
587.   	unsigned char exitData[8];
588.   	long ruleArrayLength = 1;

engines/e_4758_cca.c:588:2: 
586.   	long exitDataLength = 0;
587.   	unsigned char exitData[8];
588. > 	long ruleArrayLength = 1;
589.   	unsigned char ruleArray[8] = "PKCS-1.2";
590.   	long dataStructureLength = 0;

engines/e_4758_cca.c:589:2: 
587.   	unsigned char exitData[8];
588.   	long ruleArrayLength = 1;
589. > 	unsigned char ruleArray[8] = "PKCS-1.2";
590.   	long dataStructureLength = 0;
591.   	unsigned char dataStructure[8];

engines/e_4758_cca.c:590:2: 
588.   	long ruleArrayLength = 1;
589.   	unsigned char ruleArray[8] = "PKCS-1.2";
590. > 	long dataStructureLength = 0;
591.   	unsigned char dataStructure[8];
592.   	long outputLength = RSA_size(rsa);

engines/e_4758_cca.c:592:2: 
590.   	long dataStructureLength = 0;
591.   	unsigned char dataStructure[8];
592. > 	long outputLength = RSA_size(rsa);
593.   	long keyTokenLength;
594.   	unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);

crypto/rsa/rsa_lib.c:272:1: start of procedure RSA_size()
  270.   	}
  271.   
  272. > int RSA_size(const RSA *r)
  273.   	{
  274.   	return(BN_num_bytes(r->n));

crypto/rsa/rsa_lib.c:274:2: 
  272.   int RSA_size(const RSA *r)
  273.   	{
  274. > 	return(BN_num_bytes(r->n));
  275.   	}
  276.   

crypto/bn/bn_lib.c:245:1: start of procedure BN_num_bits()
    243.   	}
    244.   
    245. > int BN_num_bits(const BIGNUM *a)
    246.   	{
    247.   	int i = a->top - 1;

crypto/bn/bn_lib.c:247:2: 
    245.   int BN_num_bits(const BIGNUM *a)
    246.   	{
    247. > 	int i = a->top - 1;
    248.   	bn_check_top(a);
    249.   

crypto/bn/bn_lib.c:250:6: Taking false branch
    248.   	bn_check_top(a);
    249.   
    250.   	if (BN_is_zero(a)) return 0;
                ^
    251.   	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
    252.   	}

crypto/bn/bn_lib.c:250:6: Taking true branch
    248.   	bn_check_top(a);
    249.   
    250.   	if (BN_is_zero(a)) return 0;
                ^
    251.   	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
    252.   	}

crypto/bn/bn_lib.c:250:6: Taking false branch
    248.   	bn_check_top(a);
    249.   
    250.   	if (BN_is_zero(a)) return 0;
                ^
    251.   	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
    252.   	}

crypto/bn/bn_lib.c:251:2: Skipping BN_num_bits_word(): empty list of specs
    249.   
    250.   	if (BN_is_zero(a)) return 0;
    251.   	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
            ^
    252.   	}
    253.   

crypto/bn/bn_lib.c:252:2: return from a call to BN_num_bits
    250.   	if (BN_is_zero(a)) return 0;
    251.   	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
    252.   	}
            ^
    253.   
    254.   void BN_clear_free(BIGNUM *a)

crypto/rsa/rsa_lib.c:275:2: return from a call to RSA_size
  273.   	{
  274.   	return(BN_num_bytes(r->n));
  275.   	}
          ^
  276.   
  277.   int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,

engines/e_4758_cca.c:594:2: 
592.   	long outputLength = RSA_size(rsa);
593.   	long keyTokenLength;
594. > 	unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
595.   
596.   	keyTokenLength = *(long*)keyToken;

crypto/rsa/rsa_lib.c:267:1: start of procedure RSA_get_ex_data()
  265.   	}
  266.   
  267. > void *RSA_get_ex_data(const RSA *r, int idx)
  268.   	{
  269.   	return(CRYPTO_get_ex_data(&r->ex_data,idx));

crypto/rsa/rsa_lib.c:269:2: 
  267.   void *RSA_get_ex_data(const RSA *r, int idx)
  268.   	{
  269. > 	return(CRYPTO_get_ex_data(&r->ex_data,idx));
  270.   	}
  271.   

crypto/ex_data.c:622:1: start of procedure CRYPTO_get_ex_data()
    620.   /* For a given CRYPTO_EX_DATA_ variable, get the value corresponding to a
    621.    * particular index in the class used by this variable */
    622. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    623.   	{
    624.   	if (ad->sk == NULL)

crypto/ex_data.c:624:6: Taking false branch
    622.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    623.   	{
    624.   	if (ad->sk == NULL)
                ^
    625.   		return(0);
    626.   	else if (idx >= sk_num(ad->sk))

crypto/ex_data.c:626:11: 
    624.   	if (ad->sk == NULL)
    625.   		return(0);
    626. > 	else if (idx >= sk_num(ad->sk))
    627.   		return(0);
    628.   	else

crypto/stack/stack.c:301:1: start of procedure sk_num()
      299.   	}
      300.   
      301. > int sk_num(const STACK *st)
      302.   {
      303.   	if(st == NULL) return -1;

crypto/stack/stack.c:303:5: Taking false branch
      301.   int sk_num(const STACK *st)
      302.   {
      303.   	if(st == NULL) return -1;
                 ^
      304.   	return st->num;
      305.   }

crypto/stack/stack.c:304:2: 
      302.   {
      303.   	if(st == NULL) return -1;
      304. > 	return st->num;
      305.   }
      306.   

crypto/stack/stack.c:305:1: return from a call to sk_num
      303.   	if(st == NULL) return -1;
      304.   	return st->num;
      305. > }
      306.   
      307.   char *sk_value(const STACK *st, int i)

crypto/ex_data.c:626:11: Taking false branch
    624.   	if (ad->sk == NULL)
    625.   		return(0);
    626.   	else if (idx >= sk_num(ad->sk))
                     ^
    627.   		return(0);
    628.   	else

crypto/ex_data.c:629:3: 
    627.   		return(0);
    628.   	else
    629. > 		return(sk_value(ad->sk,idx));
    630.   	}
    631.   

crypto/stack/stack.c:307:1: start of procedure sk_value()
      305.   }
      306.   
      307. > char *sk_value(const STACK *st, int i)
      308.   {
      309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:309:6: Taking false branch
      307.   char *sk_value(const STACK *st, int i)
      308.   {
      309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                  ^
      310.   	return st->data[i];
      311.   }

crypto/stack/stack.c:309:13: Taking true branch
      307.   char *sk_value(const STACK *st, int i)
      308.   {
      309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                         ^
      310.   	return st->data[i];
      311.   }

crypto/stack/stack.c:309:39: 
      307.   char *sk_value(const STACK *st, int i)
      308.   {
      309. > 	if(!st || (i < 0) || (i >= st->num)) return NULL;
      310.   	return st->data[i];
      311.   }

crypto/stack/stack.c:311:1: return from a call to sk_value
      309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
      310.   	return st->data[i];
      311. > }
      312.   
      313.   char *sk_set(STACK *st, int i, char *value)

crypto/ex_data.c:630:2: return from a call to CRYPTO_get_ex_data
    628.   	else
    629.   		return(sk_value(ad->sk,idx));
    630.   	}
            ^
    631.   
    632.   IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS)

crypto/rsa/rsa_lib.c:270:2: return from a call to RSA_get_ex_data
  268.   	{
  269.   	return(CRYPTO_get_ex_data(&r->ex_data,idx));
  270.   	}
          ^
  271.   
  272.   int RSA_size(const RSA *r)

engines/e_4758_cca.c:596:2: 
594.   	unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
595.   
596. > 	keyTokenLength = *(long*)keyToken;
597.   	keyToken+=sizeof(long);
598.   

static int cca_rsa_priv_dec(int flen, const unsigned char *from,
			unsigned char *to, RSA *rsa,int padding)
	{
	long returnCode;
	long reasonCode;
	long lflen = flen;
	long exitDataLength = 0;
	unsigned char exitData[8];
	long ruleArrayLength = 1;
	unsigned char ruleArray[8] = "PKCS-1.2";
	long dataStructureLength = 0;
	unsigned char dataStructure[8];
	long outputLength = RSA_size(rsa);
	long keyTokenLength;
	unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
	keyTokenLength = *(long*)keyToken;
	keyToken+=sizeof(long);
	pkaDecrypt(&returnCode, &reasonCode, &exitDataLength, exitData,
		&ruleArrayLength, ruleArray, &lflen, (unsigned char*)from,
		&dataStructureLength, dataStructure, &keyTokenLength,
		keyToken, &outputLength, to);
	return (returnCode | reasonCode) ? 0 : 1;
	}
['static int cca_rsa_priv_dec(int flen, const unsigned char *from,\n\t\t\tunsigned char *to, RSA *rsa,int padding)\n\t{\n\tlong returnCode;\n\tlong reasonCode;\n\tlong lflen = flen;\n\tlong exitDataLength = 0;\n\tunsigned char exitData[8];\n\tlong ruleArrayLength = 1;\n\tunsigned char ruleArray[8] = "PKCS-1.2";\n\tlong dataStructureLength = 0;\n\tunsigned char dataStructure[8];\n\tlong outputLength = RSA_size(rsa);\n\tlong keyTokenLength;\n\tunsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);\n\tkeyTokenLength = *(long*)keyToken;\n\tkeyToken+=sizeof(long);\n\tpkaDecrypt(&returnCode, &reasonCode, &exitDataLength, exitData,\n\t\t&ruleArrayLength, ruleArray, &lflen, (unsigned char*)from,\n\t\t&dataStructureLength, dataStructure, &keyTokenLength,\n\t\tkeyToken, &outputLength, to);\n\treturn (returnCode | reasonCode) ? 0 : 1;\n\t}', 'int RSA_size(const RSA *r)\n\t{\n\treturn(BN_num_bytes(r->n));\n\t}', 'int BN_num_bits(const BIGNUM *a)\n\t{\n\tint i = a->top - 1;\n\tbn_check_top(a);\n\tif (BN_is_zero(a)) return 0;\n\treturn ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));\n\t}', 'void *RSA_get_ex_data(const RSA *r, int idx)\n\t{\n\treturn(CRYPTO_get_ex_data(&r->ex_data,idx));\n\t}', 'void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)\n\t{\n\tif (ad->sk == NULL)\n\t\treturn(0);\n\telse if (idx >= sk_num(ad->sk))\n\t\treturn(0);\n\telse\n\t\treturn(sk_value(ad->sk,idx));\n\t}', 'int sk_num(const STACK *st)\n{\n\tif(st == NULL) return -1;\n\treturn st->num;\n}', 'char *sk_value(const STACK *st, int i)\n{\n\tif(!st || (i < 0) || (i >= st->num)) return NULL;\n\treturn st->data[i];\n}']