engines/e_4758cca.c:578: error: NULL_DEREFERENCE
  pointer `keyToken` last assigned on line 576 could be null and is dereferenced at line 578, column 19.
Showing all 42 steps of the trace


engines/e_4758cca.c:562:1: start of procedure cca_rsa_pub_enc()
560.   	}
561.   
562. > static int cca_rsa_pub_enc(int flen, const unsigned char *from,
563.   			unsigned char *to, RSA *rsa,int padding)
564.   	{

engines/e_4758cca.c:567:2: 
565.   	long returnCode;
566.   	long reasonCode;
567. > 	long lflen = flen;
568.   	long exitDataLength = 0;
569.   	unsigned char exitData[8];

engines/e_4758cca.c:568:2: 
566.   	long reasonCode;
567.   	long lflen = flen;
568. > 	long exitDataLength = 0;
569.   	unsigned char exitData[8];
570.   	long ruleArrayLength = 1;

engines/e_4758cca.c:570:2: 
568.   	long exitDataLength = 0;
569.   	unsigned char exitData[8];
570. > 	long ruleArrayLength = 1;
571.   	unsigned char ruleArray[8] = "PKCS-1.2";
572.   	long dataStructureLength = 0;

engines/e_4758cca.c:571:2: 
569.   	unsigned char exitData[8];
570.   	long ruleArrayLength = 1;
571. > 	unsigned char ruleArray[8] = "PKCS-1.2";
572.   	long dataStructureLength = 0;
573.   	unsigned char dataStructure[8];

engines/e_4758cca.c:572:2: 
570.   	long ruleArrayLength = 1;
571.   	unsigned char ruleArray[8] = "PKCS-1.2";
572. > 	long dataStructureLength = 0;
573.   	unsigned char dataStructure[8];
574.   	long outputLength = RSA_size(rsa);

engines/e_4758cca.c:574:2: 
572.   	long dataStructureLength = 0;
573.   	unsigned char dataStructure[8];
574. > 	long outputLength = RSA_size(rsa);
575.   	long keyTokenLength;
576.   	unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);

crypto/rsa/rsa_crpt.c:69:1: start of procedure RSA_size()
  67.   #include <openssl/rand.h>
  68.   
  69. > int RSA_size(const RSA *r)
  70.   	{
  71.   	return(BN_num_bytes(r->n));

crypto/rsa/rsa_crpt.c:71:2: 
  69.   int RSA_size(const RSA *r)
  70.   	{
  71. > 	return(BN_num_bytes(r->n));
  72.   	}
  73.   

crypto/bn/bn_lib.c:230:1: start of procedure BN_num_bits()
    228.   	}
    229.   
    230. > int BN_num_bits(const BIGNUM *a)
    231.   	{
    232.   	int i = a->top - 1;

crypto/bn/bn_lib.c:232:2: 
    230.   int BN_num_bits(const BIGNUM *a)
    231.   	{
    232. > 	int i = a->top - 1;
    233.   	bn_check_top(a);
    234.   

crypto/bn/bn_lib.c:235:6: 
    233.   	bn_check_top(a);
    234.   
    235. > 	if (BN_is_zero(a)) return 0;
    236.   	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
    237.   	}

crypto/bn/bn_lib.c:927:1: start of procedure BN_is_zero()
      925.   	}
      926.   
      927. > int BN_is_zero(const BIGNUM *a)
      928.   	{
      929.   	return a->top == 0;

crypto/bn/bn_lib.c:929:9: Condition is false
      927.   int BN_is_zero(const BIGNUM *a)
      928.   	{
      929.   	return a->top == 0;
                     ^
      930.   	}
      931.   

crypto/bn/bn_lib.c:929:2: 
      927.   int BN_is_zero(const BIGNUM *a)
      928.   	{
      929. > 	return a->top == 0;
      930.   	}
      931.   

crypto/bn/bn_lib.c:930:2: return from a call to BN_is_zero
      928.   	{
      929.   	return a->top == 0;
      930.   	}
              ^
      931.   
      932.   int BN_is_one(const BIGNUM *a)

crypto/bn/bn_lib.c:235:6: Taking false branch
    233.   	bn_check_top(a);
    234.   
    235.   	if (BN_is_zero(a)) return 0;
                ^
    236.   	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
    237.   	}

crypto/bn/bn_lib.c:236:2: Skipping BN_num_bits_word(): empty list of specs
    234.   
    235.   	if (BN_is_zero(a)) return 0;
    236.   	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
            ^
    237.   	}
    238.   

crypto/bn/bn_lib.c:237:2: return from a call to BN_num_bits
    235.   	if (BN_is_zero(a)) return 0;
    236.   	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
    237.   	}
            ^
    238.   
    239.   void BN_clear_free(BIGNUM *a)

crypto/rsa/rsa_crpt.c:72:2: return from a call to RSA_size
  70.   	{
  71.   	return(BN_num_bytes(r->n));
  72.   	}
         ^
  73.   
  74.   int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,

engines/e_4758cca.c:576:2: 
574.   	long outputLength = RSA_size(rsa);
575.   	long keyTokenLength;
576. > 	unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
577.   
578.   	keyTokenLength = *(long*)keyToken;

crypto/rsa/rsa_lib.c:274:1: start of procedure RSA_get_ex_data()
  272.   	}
  273.   
  274. > void *RSA_get_ex_data(const RSA *r, int idx)
  275.   	{
  276.   	return(CRYPTO_get_ex_data(&r->ex_data,idx));

crypto/rsa/rsa_lib.c:276:2: 
  274.   void *RSA_get_ex_data(const RSA *r, int idx)
  275.   	{
  276. > 	return(CRYPTO_get_ex_data(&r->ex_data,idx));
  277.   	}
  278.   

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_void_num(ad->sk))

crypto/ex_data.c:630:18: Condition is true
    628.   	if (ad->sk == NULL)
    629.   		return(0);
    630.   	else if (idx >= sk_void_num(ad->sk))
                            ^
    631.   		return(0);
    632.   	else

crypto/ex_data.c:630:11: 
    628.   	if (ad->sk == NULL)
    629.   		return(0);
    630. > 	else if (idx >= sk_void_num(ad->sk))
    631.   		return(0);
    632.   	else

crypto/stack/stack.c:331:1: start of procedure sk_num()
      329.   	}
      330.   
      331. > int sk_num(const _STACK *st)
      332.   {
      333.   	if(st == NULL) return -1;

crypto/stack/stack.c:333:5: Taking false branch
      331.   int sk_num(const _STACK *st)
      332.   {
      333.   	if(st == NULL) return -1;
                 ^
      334.   	return st->num;
      335.   }

crypto/stack/stack.c:334:2: 
      332.   {
      333.   	if(st == NULL) return -1;
      334. > 	return st->num;
      335.   }
      336.   

crypto/stack/stack.c:335:1: return from a call to sk_num
      333.   	if(st == NULL) return -1;
      334.   	return st->num;
      335. > }
      336.   
      337.   void *sk_value(const _STACK *st, int i)

crypto/ex_data.c:630:11: Taking false branch
    628.   	if (ad->sk == NULL)
    629.   		return(0);
    630.   	else if (idx >= sk_void_num(ad->sk))
                     ^
    631.   		return(0);
    632.   	else

crypto/ex_data.c:633:10: Condition is true
    631.   		return(0);
    632.   	else
    633.   		return(sk_void_value(ad->sk,idx));
                    ^
    634.   	}
    635.   

crypto/ex_data.c:633:3: 
    631.   		return(0);
    632.   	else
    633. > 		return(sk_void_value(ad->sk,idx));
    634.   	}
    635.   

crypto/stack/stack.c:337:1: start of procedure sk_value()
      335.   }
      336.   
      337. > void *sk_value(const _STACK *st, int i)
      338.   {
      339.   	if(!st || (i < 0) || (i >= st->num)) return NULL;

crypto/stack/stack.c:339:6: Taking false branch
      337.   void *sk_value(const _STACK *st, int i)
      338.   {
      339.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                  ^
      340.   	return st->data[i];
      341.   }

crypto/stack/stack.c:339:13: Taking true branch
      337.   void *sk_value(const _STACK *st, int i)
      338.   {
      339.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
                         ^
      340.   	return st->data[i];
      341.   }

crypto/stack/stack.c:339:39: 
      337.   void *sk_value(const _STACK *st, int i)
      338.   {
      339. > 	if(!st || (i < 0) || (i >= st->num)) return NULL;
      340.   	return st->data[i];
      341.   }

crypto/stack/stack.c:341:1: return from a call to sk_value
      339.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
      340.   	return st->data[i];
      341. > }
      342.   
      343.   void *sk_set(_STACK *st, int i, void *value)

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

crypto/rsa/rsa_lib.c:277:2: return from a call to RSA_get_ex_data
  275.   	{
  276.   	return(CRYPTO_get_ex_data(&r->ex_data,idx));
  277.   	}
          ^
  278.   
  279.   int RSA_memory_lock(RSA *r)

engines/e_4758cca.c:578:2: 
576.   	unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
577.   
578. > 	keyTokenLength = *(long*)keyToken;
579.   	keyToken+=sizeof(long);
580.   

static int cca_rsa_pub_enc(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);
	pkaEncrypt(&returnCode, &reasonCode, &exitDataLength, exitData,
		&ruleArrayLength, ruleArray, &lflen, (unsigned char*)from,
		&dataStructureLength, dataStructure, &keyTokenLength,
		keyToken, &outputLength, to);
	if (returnCode || reasonCode)
		return -(returnCode << 16 | reasonCode);
	return outputLength;
	}
['static int cca_rsa_pub_enc(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\tpkaEncrypt(&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\tif (returnCode || reasonCode)\n\t\treturn -(returnCode << 16 | reasonCode);\n\treturn outputLength;\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}', 'int BN_is_zero(const BIGNUM *a)\n\t{\n\treturn a->top == 0;\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_void_num(ad->sk))\n\t\treturn(0);\n\telse\n\t\treturn(sk_void_value(ad->sk,idx));\n\t}', 'int sk_num(const _STACK *st)\n{\n\tif(st == NULL) return -1;\n\treturn st->num;\n}', 'void *sk_value(const _STACK *st, int i)\n{\n\tif(!st || (i < 0) || (i >= st->num)) return NULL;\n\treturn st->data[i];\n}']