engines/e_sureware.c:1005: error: NULL_DEREFERENCE
  pointer `psign` last assigned on line 974 could be null and is dereferenced at line 1005, column 2.
Showing all 54 steps of the trace


engines/e_sureware.c:970:1: start of procedure surewarehk_dsa_do_sign()
968.   #ifndef OPENSSL_NO_DSA
969.   /* DSA sign and verify */
970. > static	DSA_SIG * surewarehk_dsa_do_sign(const unsigned char *from, int flen, DSA *dsa)
971.   {
972.   	int ret=0;

engines/e_sureware.c:972:2: 
970.   static	DSA_SIG * surewarehk_dsa_do_sign(const unsigned char *from, int flen, DSA *dsa)
971.   {
972. > 	int ret=0;
973.   	char *hptr=NULL;
974.   	DSA_SIG *psign=NULL;

engines/e_sureware.c:973:2: 
971.   {
972.   	int ret=0;
973. > 	char *hptr=NULL;
974.   	DSA_SIG *psign=NULL;
975.   	char msg[64]="ENGINE_dsa_do_sign";

engines/e_sureware.c:974:2: 
972.   	int ret=0;
973.   	char *hptr=NULL;
974. > 	DSA_SIG *psign=NULL;
975.   	char msg[64]="ENGINE_dsa_do_sign";
976.   	if (!p_surewarehk_Dsa_Sign)

engines/e_sureware.c:975:2: 
973.   	char *hptr=NULL;
974.   	DSA_SIG *psign=NULL;
975. > 	char msg[64]="ENGINE_dsa_do_sign";
976.   	if (!p_surewarehk_Dsa_Sign)
977.   	{

engines/e_sureware.c:976:7: Taking false branch
974.   	DSA_SIG *psign=NULL;
975.   	char msg[64]="ENGINE_dsa_do_sign";
976.   	if (!p_surewarehk_Dsa_Sign)
             ^
977.   	{
978.   		SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ENGINE_R_NOT_INITIALISED);

engines/e_sureware.c:981:13: 
979.   	}
980.   	/* extract ref to private key */
981. > 	else if (!(hptr=DSA_get_ex_data(dsa, dsaHndidx)))
982.   	{
983.   		SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,SUREWARE_R_MISSING_KEY_COMPONENTS);

crypto/dsa/dsa_lib.c:270:1: start of procedure DSA_get_ex_data()
  268.   	}
  269.   
  270. > void *DSA_get_ex_data(DSA *d, int idx)
  271.   	{
  272.   	return(CRYPTO_get_ex_data(&d->ex_data,idx));

crypto/dsa/dsa_lib.c:272:2: 
  270.   void *DSA_get_ex_data(DSA *d, int idx)
  271.   	{
  272. > 	return(CRYPTO_get_ex_data(&d->ex_data,idx));
  273.   	}
  274.   

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 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:24: 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:310:2: 
      308.   {
      309.   	if(!st || (i < 0) || (i >= st->num)) return NULL;
      310. > 	return st->data[i];
      311.   }
      312.   

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/dsa/dsa_lib.c:273:2: return from a call to DSA_get_ex_data
  271.   	{
  272.   	return(CRYPTO_get_ex_data(&d->ex_data,idx));
  273.   	}
          ^
  274.   
  275.   #ifndef OPENSSL_NO_DH

engines/e_sureware.c:981:13: Taking true branch
979.   	}
980.   	/* extract ref to private key */
981.   	else if (!(hptr=DSA_get_ex_data(dsa, dsaHndidx)))
                   ^
982.   	{
983.   		SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,SUREWARE_R_MISSING_KEY_COMPONENTS);

engines/e_sureware.c:983:3: 
981.   	else if (!(hptr=DSA_get_ex_data(dsa, dsaHndidx)))
982.   	{
983. > 		SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,SUREWARE_R_MISSING_KEY_COMPONENTS);
984.   	}
985.   	else

engines/e_sureware_err.c:153:1: start of procedure ERR_SUREWARE_error()
  151.   	}
  152.   
  153. > static void ERR_SUREWARE_error(int function, int reason, char *file, int line)
  154.   	{
  155.   	if (SUREWARE_lib_error_code == 0)

engines/e_sureware_err.c:155:6: Taking true branch
  153.   static void ERR_SUREWARE_error(int function, int reason, char *file, int line)
  154.   	{
  155.   	if (SUREWARE_lib_error_code == 0)
              ^
  156.   		SUREWARE_lib_error_code=ERR_get_next_error_library();
  157.   	ERR_PUT_error(SUREWARE_lib_error_code,function,reason,file,line);

engines/e_sureware_err.c:156:3: 
  154.   	{
  155.   	if (SUREWARE_lib_error_code == 0)
  156. > 		SUREWARE_lib_error_code=ERR_get_next_error_library();
  157.   	ERR_PUT_error(SUREWARE_lib_error_code,function,reason,file,line);
  158.   	}

crypto/err/err.c:1026:1: start of procedure ERR_get_next_error_library()
    1024.   	}
    1025.   
    1026. > int ERR_get_next_error_library(void)
    1027.   	{
    1028.   	err_fns_check();

crypto/err/err.c:1028:2: 
    1026.   int ERR_get_next_error_library(void)
    1027.   	{
    1028. > 	err_fns_check();
    1029.   	return ERRFN(get_next_lib)();
    1030.   	}

crypto/err/err.c:283:1: start of procedure err_fns_check()
      281.   /* Internal function that checks whether "err_fns" is set and if not, sets it to
      282.    * the defaults. */
      283. > static void err_fns_check(void)
      284.   	{
      285.   	if (err_fns) return;

crypto/err/err.c:285:6: Taking true branch
      283.   static void err_fns_check(void)
      284.   	{
      285.   	if (err_fns) return;
                  ^
      286.   	
      287.   	CRYPTO_w_lock(CRYPTO_LOCK_ERR);

crypto/err/err.c:285:15: 
      283.   static void err_fns_check(void)
      284.   	{
      285. > 	if (err_fns) return;
      286.   	
      287.   	CRYPTO_w_lock(CRYPTO_LOCK_ERR);

crypto/err/err.c:291:2: return from a call to err_fns_check
      289.   		err_fns = &err_defaults;
      290.   	CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
      291.   	}
              ^
      292.   
      293.   /* API functions to get or set the underlying ERR functions. */

crypto/err/err.c:1029:2: Skipping __function_pointer__(): unresolved function pointer
    1027.   	{
    1028.   	err_fns_check();
    1029.   	return ERRFN(get_next_lib)();
             ^
    1030.   	}
    1031.   

crypto/err/err.c:1030:2: return from a call to ERR_get_next_error_library
    1028.   	err_fns_check();
    1029.   	return ERRFN(get_next_lib)();
    1030.   	}
             ^
    1031.   
    1032.   void ERR_set_error_data(char *data, int flags)

engines/e_sureware_err.c:157:2: 
  155.   	if (SUREWARE_lib_error_code == 0)
  156.   		SUREWARE_lib_error_code=ERR_get_next_error_library();
  157. > 	ERR_PUT_error(SUREWARE_lib_error_code,function,reason,file,line);
  158.   	}

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)

engines/e_sureware_err.c:158:2: return from a call to ERR_SUREWARE_error
  156.   		SUREWARE_lib_error_code=ERR_get_next_error_library();
  157.   	ERR_PUT_error(SUREWARE_lib_error_code,function,reason,file,line);
  158.   	}
          ^

engines/e_sureware.c:1005:2: 
1003.   		surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ret);
1004.   	}
1005. > 	psign->r->top=20/sizeof(BN_ULONG);
1006.   	bn_fix_top(psign->r);
1007.   	psign->s->top=20/sizeof(BN_ULONG);

static	DSA_SIG * surewarehk_dsa_do_sign(const unsigned char *from, int flen, DSA *dsa)
{
	int ret=0;
	char *hptr=NULL;
	DSA_SIG *psign=NULL;
	char msg[64]="ENGINE_dsa_do_sign";
	if (!p_surewarehk_Dsa_Sign)
	{
		SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ENGINE_R_NOT_INITIALISED);
	}
	else if (!(hptr=DSA_get_ex_data(dsa, dsaHndidx)))
	{
		SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,SUREWARE_R_MISSING_KEY_COMPONENTS);
	}
	else
	{
		if((psign = DSA_SIG_new()) == NULL)
		{
			SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ERR_R_MALLOC_FAILURE);
			goto err;
		}
		psign->r=BN_new();
		psign->s=BN_new();
		bn_expand2(psign->r, 20/sizeof(BN_ULONG));
		bn_expand2(psign->s, 20/sizeof(BN_ULONG));
		if (!psign->r || psign->r->dmax!=20/sizeof(BN_ULONG) ||
			!psign->s || psign->s->dmax!=20/sizeof(BN_ULONG))
			goto err;
		ret=p_surewarehk_Dsa_Sign(msg,flen,from,
					  (unsigned long *)psign->r->d,
					  (unsigned long *)psign->s->d,
					  hptr);
		surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ret);
	}
	psign->r->top=20/sizeof(BN_ULONG);
	bn_fix_top(psign->r);
	psign->s->top=20/sizeof(BN_ULONG);
	bn_fix_top(psign->s);
err:
	if (psign)
	{
		DSA_SIG_free(psign);
		psign=NULL;
	}
	return psign;
}
['static\tDSA_SIG * surewarehk_dsa_do_sign(const unsigned char *from, int flen, DSA *dsa)\n{\n\tint ret=0;\n\tchar *hptr=NULL;\n\tDSA_SIG *psign=NULL;\n\tchar msg[64]="ENGINE_dsa_do_sign";\n\tif (!p_surewarehk_Dsa_Sign)\n\t{\n\t\tSUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ENGINE_R_NOT_INITIALISED);\n\t}\n\telse if (!(hptr=DSA_get_ex_data(dsa, dsaHndidx)))\n\t{\n\t\tSUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,SUREWARE_R_MISSING_KEY_COMPONENTS);\n\t}\n\telse\n\t{\n\t\tif((psign = DSA_SIG_new()) == NULL)\n\t\t{\n\t\t\tSUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ERR_R_MALLOC_FAILURE);\n\t\t\tgoto err;\n\t\t}\n\t\tpsign->r=BN_new();\n\t\tpsign->s=BN_new();\n\t\tbn_expand2(psign->r, 20/sizeof(BN_ULONG));\n\t\tbn_expand2(psign->s, 20/sizeof(BN_ULONG));\n\t\tif (!psign->r || psign->r->dmax!=20/sizeof(BN_ULONG) ||\n\t\t\t!psign->s || psign->s->dmax!=20/sizeof(BN_ULONG))\n\t\t\tgoto err;\n\t\tret=p_surewarehk_Dsa_Sign(msg,flen,from,\n\t\t\t\t\t  (unsigned long *)psign->r->d,\n\t\t\t\t\t  (unsigned long *)psign->s->d,\n\t\t\t\t\t  hptr);\n\t\tsurewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ret);\n\t}\n\tpsign->r->top=20/sizeof(BN_ULONG);\n\tbn_fix_top(psign->r);\n\tpsign->s->top=20/sizeof(BN_ULONG);\n\tbn_fix_top(psign->s);\nerr:\n\tif (psign)\n\t{\n\t\tDSA_SIG_free(psign);\n\t\tpsign=NULL;\n\t}\n\treturn psign;\n}', 'void *DSA_get_ex_data(DSA *d, int idx)\n\t{\n\treturn(CRYPTO_get_ex_data(&d->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}', 'static void ERR_SUREWARE_error(int function, int reason, char *file, int line)\n\t{\n\tif (SUREWARE_lib_error_code == 0)\n\t\tSUREWARE_lib_error_code=ERR_get_next_error_library();\n\tERR_PUT_error(SUREWARE_lib_error_code,function,reason,file,line);\n\t}', 'int ERR_get_next_error_library(void)\n\t{\n\terr_fns_check();\n\treturn ERRFN(get_next_lib)();\n\t}', 'static void err_fns_check(void)\n\t{\n\tif (err_fns) return;\n\tCRYPTO_w_lock(CRYPTO_LOCK_ERR);\n\tif (!err_fns)\n\t\terr_fns = &err_defaults;\n\tCRYPTO_w_unlock(CRYPTO_LOCK_ERR);\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}']