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


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

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

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

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

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

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

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

crypto/rsa/rsa_lib.c:259:1: start of procedure RSA_size()
  257.   	}
  258.   
  259. > int RSA_size(const RSA *r)
  260.   	{
  261.   	return(BN_num_bytes(r->n));

crypto/rsa/rsa_lib.c:261:2: 
  259.   int RSA_size(const RSA *r)
  260.   	{
  261. > 	return(BN_num_bytes(r->n));
  262.   	}
  263.   

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.   	BN_ULONG l;

crypto/bn/bn_lib.c:252:6: Taking false branch
    250.   	bn_check_top(a);
    251.   
    252.   	if (a->top == 0) return(0);
                ^
    253.   	l=a->d[a->top-1];
    254.   	assert(l != 0);

crypto/bn/bn_lib.c:253:2: 
    251.   
    252.   	if (a->top == 0) return(0);
    253. > 	l=a->d[a->top-1];
    254.   	assert(l != 0);
    255.   	i=(a->top-1)*BN_BITS2;

crypto/bn/bn_lib.c:254:2: 
    252.   	if (a->top == 0) return(0);
    253.   	l=a->d[a->top-1];
    254. > 	assert(l != 0);
    255.   	i=(a->top-1)*BN_BITS2;
    256.   	return(i+BN_num_bits_word(l));

crypto/bn/bn_lib.c:255:2: 
    253.   	l=a->d[a->top-1];
    254.   	assert(l != 0);
    255. > 	i=(a->top-1)*BN_BITS2;
    256.   	return(i+BN_num_bits_word(l));
    257.   	}

crypto/bn/bn_lib.c:256:2: Skipping BN_num_bits_word(): empty list of specs
    254.   	assert(l != 0);
    255.   	i=(a->top-1)*BN_BITS2;
    256.   	return(i+BN_num_bits_word(l));
            ^
    257.   	}
    258.   

crypto/bn/bn_lib.c:257:2: return from a call to BN_num_bits
    255.   	i=(a->top-1)*BN_BITS2;
    256.   	return(i+BN_num_bits_word(l));
    257.   	}
            ^
    258.   
    259.   void BN_clear_free(BIGNUM *a)

crypto/rsa/rsa_lib.c:262:2: return from a call to RSA_size
  260.   	{
  261.   	return(BN_num_bytes(r->n));
  262.   	}
          ^
  263.   
  264.   int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,

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

crypto/rsa/rsa_lib.c:254:1: start of procedure RSA_get_ex_data()
  252.   	}
  253.   
  254. > void *RSA_get_ex_data(const RSA *r, int idx)
  255.   	{
  256.   	return(CRYPTO_get_ex_data(&r->ex_data,idx));

crypto/rsa/rsa_lib.c:256:2: 
  254.   void *RSA_get_ex_data(const RSA *r, int idx)
  255.   	{
  256. > 	return(CRYPTO_get_ex_data(&r->ex_data,idx));
  257.   	}
  258.   

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

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

crypto/ex_data.c:630:11: 
    628.   	if (ad->sk == NULL)
    629.   		return(0);
    630. > 	else if (idx >= sk_num(ad->sk))
    631.   		return(0);
    632.   	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:630:11: Taking true branch
    628.   	if (ad->sk == NULL)
    629.   		return(0);
    630.   	else if (idx >= sk_num(ad->sk))
                     ^
    631.   		return(0);
    632.   	else

crypto/ex_data.c:631:3: 
    629.   		return(0);
    630.   	else if (idx >= sk_num(ad->sk))
    631. > 		return(0);
    632.   	else
    633.   		return(sk_value(ad->sk,idx));

crypto/ex_data.c:634:2: return from a call to CRYPTO_get_ex_data
    632.   	else
    633.   		return(sk_value(ad->sk,idx));
    634.   	}
            ^
    635.   
    636.   IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS)

crypto/rsa/rsa_lib.c:257:2: return from a call to RSA_get_ex_data
  255.   	{
  256.   	return(CRYPTO_get_ex_data(&r->ex_data,idx));
  257.   	}
          ^
  258.   
  259.   int RSA_size(const RSA *r)

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

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\tBN_ULONG l;\n\tint i;\n\tbn_check_top(a);\n\tif (a->top == 0) return(0);\n\tl=a->d[a->top-1];\n\tassert(l != 0);\n\ti=(a->top-1)*BN_BITS2;\n\treturn(i+BN_num_bits_word(l));\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}']