engines/ccgost/gost2001.c:287: error: NULL_DEREFERENCE
  pointer `ctx` last assigned on line 286 could be null and is dereferenced by call to `BN_CTX_start()` at line 287, column 2.
Showing all 45 steps of the trace


engines/ccgost/gost2001.c:273:1: start of procedure gost2001_compute_public()
271.    *
272.    */ 
273. > int gost2001_compute_public(EC_KEY *ec) 
274.   	{
275.   	const EC_GROUP *group = EC_KEY_get0_group(ec);

engines/ccgost/gost2001.c:275:2: 
273.   int gost2001_compute_public(EC_KEY *ec) 
274.   	{
275. > 	const EC_GROUP *group = EC_KEY_get0_group(ec);
276.   	EC_POINT *pub_key=NULL;
277.   	const BIGNUM *priv_key=NULL;

crypto/ec/ec_key.c:376:1: start of procedure EC_KEY_get0_group()
  374.   	}
  375.   
  376. > const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
  377.   	{
  378.   	return key->group;

crypto/ec/ec_key.c:378:2: 
  376.   const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
  377.   	{
  378. > 	return key->group;
  379.   	}
  380.   

crypto/ec/ec_key.c:379:2: return from a call to EC_KEY_get0_group
  377.   	{
  378.   	return key->group;
  379.   	}
          ^
  380.   
  381.   int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group)

engines/ccgost/gost2001.c:276:2: 
274.   	{
275.   	const EC_GROUP *group = EC_KEY_get0_group(ec);
276. > 	EC_POINT *pub_key=NULL;
277.   	const BIGNUM *priv_key=NULL;
278.   	BN_CTX *ctx=NULL;

engines/ccgost/gost2001.c:277:2: 
275.   	const EC_GROUP *group = EC_KEY_get0_group(ec);
276.   	EC_POINT *pub_key=NULL;
277. > 	const BIGNUM *priv_key=NULL;
278.   	BN_CTX *ctx=NULL;
279.   	int ok=0;

engines/ccgost/gost2001.c:278:2: 
276.   	EC_POINT *pub_key=NULL;
277.   	const BIGNUM *priv_key=NULL;
278. > 	BN_CTX *ctx=NULL;
279.   	int ok=0;
280.   

engines/ccgost/gost2001.c:279:2: 
277.   	const BIGNUM *priv_key=NULL;
278.   	BN_CTX *ctx=NULL;
279. > 	int ok=0;
280.   
281.   	if (!group)

engines/ccgost/gost2001.c:281:7: Taking false branch
279.   	int ok=0;
280.   
281.   	if (!group)
             ^
282.   		{
283.   		GOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC,GOST_R_KEY_IS_NOT_INITIALIZED);

engines/ccgost/gost2001.c:286:2: 
284.   		return 0;
285.   		}	
286. > 	ctx=BN_CTX_new();
287.   	BN_CTX_start(ctx);
288.   	if (!(priv_key=EC_KEY_get0_private_key(ec))) 

crypto/bn/bn_ctx.c:214:1: start of procedure BN_CTX_new()
  212.   #endif
  213.   
  214. > BN_CTX *BN_CTX_new(void)
  215.   	{
  216.   	BN_CTX *ret = OPENSSL_malloc(sizeof(BN_CTX));

crypto/bn/bn_ctx.c:216:2: 
  214.   BN_CTX *BN_CTX_new(void)
  215.   	{
  216. > 	BN_CTX *ret = OPENSSL_malloc(sizeof(BN_CTX));
  217.   	if(!ret)
  218.   		{

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/bn/bn_ctx.c:217:6: Taking true branch
  215.   	{
  216.   	BN_CTX *ret = OPENSSL_malloc(sizeof(BN_CTX));
  217.   	if(!ret)
              ^
  218.   		{
  219.   		BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);

crypto/bn/bn_ctx.c:219:3: 
  217.   	if(!ret)
  218.   		{
  219. > 		BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);
  220.   		return NULL;
  221.   		}

crypto/err/err.c:679:1: start of procedure ERR_put_error()
    677.   /********************************************************/
    678.   
    679. > void ERR_put_error(int lib, int func, int reason, const char *file,
    680.   	     int line)
    681.   	{

crypto/err/err.c:703:2: Skipping ERR_get_state(): empty list of specs
    701.   	}
    702.   #endif
    703.   	es=ERR_get_state();
            ^
    704.   
    705.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:705:2: 
    703.   	es=ERR_get_state();
    704.   
    705. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
    706.   	if (es->top == es->bottom)
    707.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:706:6: Taking false branch
    704.   
    705.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
    706.   	if (es->top == es->bottom)
                ^
    707.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    708.   	es->err_flags[es->top]=0;

crypto/err/err.c:708:2: 
    706.   	if (es->top == es->bottom)
    707.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    708. > 	es->err_flags[es->top]=0;
    709.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    710.   	es->err_file[es->top]=file;

crypto/err/err.c:709:2: 
    707.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    708.   	es->err_flags[es->top]=0;
    709. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    710.   	es->err_file[es->top]=file;
    711.   	es->err_line[es->top]=line;

crypto/err/err.c:710:2: 
    708.   	es->err_flags[es->top]=0;
    709.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    710. > 	es->err_file[es->top]=file;
    711.   	es->err_line[es->top]=line;
    712.   	err_clear_data(es,es->top);

crypto/err/err.c:711:2: 
    709.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    710.   	es->err_file[es->top]=file;
    711. > 	es->err_line[es->top]=line;
    712.   	err_clear_data(es,es->top);
    713.   	}

crypto/err/err.c:712:2: Taking true branch
    710.   	es->err_file[es->top]=file;
    711.   	es->err_line[es->top]=line;
    712.   	err_clear_data(es,es->top);
            ^
    713.   	}
    714.   

crypto/err/err.c:712:2: Taking false branch
    710.   	es->err_file[es->top]=file;
    711.   	es->err_line[es->top]=line;
    712.   	err_clear_data(es,es->top);
            ^
    713.   	}
    714.   

crypto/err/err.c:712:2: Loop condition is false. Leaving loop
    710.   	es->err_file[es->top]=file;
    711.   	es->err_line[es->top]=line;
    712.   	err_clear_data(es,es->top);
            ^
    713.   	}
    714.   

crypto/err/err.c:713:2: return from a call to ERR_put_error
    711.   	es->err_line[es->top]=line;
    712.   	err_clear_data(es,es->top);
    713.   	}
            ^
    714.   
    715.   void ERR_clear_error(void)

crypto/bn/bn_ctx.c:220:3: 
  218.   		{
  219.   		BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);
  220. > 		return NULL;
  221.   		}
  222.   	/* Initialise the structure */

crypto/bn/bn_ctx.c:229:2: return from a call to BN_CTX_new
  227.   	ret->too_many = 0;
  228.   	return ret;
  229.   	}
          ^
  230.   
  231.   void BN_CTX_free(BN_CTX *ctx)

engines/ccgost/gost2001.c:287:2: 
285.   		}	
286.   	ctx=BN_CTX_new();
287. > 	BN_CTX_start(ctx);
288.   	if (!(priv_key=EC_KEY_get0_private_key(ec))) 
289.   		{

crypto/bn/bn_ctx.c:255:1: start of procedure BN_CTX_start()
  253.   	}
  254.   
  255. > void BN_CTX_start(BN_CTX *ctx)
  256.   	{
  257.   	CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_ctx.c:259:5: Taking false branch
  257.   	CTXDBG_ENTRY("BN_CTX_start", ctx);
  258.   	/* If we're already overflowing ... */
  259.   	if(ctx->err_stack || ctx->too_many)
             ^
  260.   		ctx->err_stack++;
  261.   	/* (Try to) get a new frame pointer */

int gost2001_compute_public(EC_KEY *ec)
	{
	const EC_GROUP *group = EC_KEY_get0_group(ec);
	EC_POINT *pub_key=NULL;
	const BIGNUM *priv_key=NULL;
	BN_CTX *ctx=NULL;
	int ok=0;
	if (!group)
		{
		GOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC,GOST_R_KEY_IS_NOT_INITIALIZED);
		return 0;
		}
	ctx=BN_CTX_new();
	BN_CTX_start(ctx);
	if (!(priv_key=EC_KEY_get0_private_key(ec)))
		{
		GOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC,ERR_R_EC_LIB);
		goto err;
		}
	pub_key = EC_POINT_new(group);
	if (!EC_POINT_mul(group,pub_key,priv_key,NULL,NULL,ctx))
		{
		GOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC,ERR_R_EC_LIB);
		goto err;
		}
	if (!EC_KEY_set_public_key(ec,pub_key))
		{
		GOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC,ERR_R_EC_LIB);
		goto err;
		}
	ok = 256;
	err:
	BN_CTX_end(ctx);
	EC_POINT_free(pub_key);
	BN_CTX_free(ctx);
	return ok;
	}
['int gost2001_compute_public(EC_KEY *ec)\n\t{\n\tconst EC_GROUP *group = EC_KEY_get0_group(ec);\n\tEC_POINT *pub_key=NULL;\n\tconst BIGNUM *priv_key=NULL;\n\tBN_CTX *ctx=NULL;\n\tint ok=0;\n\tif (!group)\n\t\t{\n\t\tGOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC,GOST_R_KEY_IS_NOT_INITIALIZED);\n\t\treturn 0;\n\t\t}\n\tctx=BN_CTX_new();\n\tBN_CTX_start(ctx);\n\tif (!(priv_key=EC_KEY_get0_private_key(ec)))\n\t\t{\n\t\tGOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC,ERR_R_EC_LIB);\n\t\tgoto err;\n\t\t}\n\tpub_key = EC_POINT_new(group);\n\tif (!EC_POINT_mul(group,pub_key,priv_key,NULL,NULL,ctx))\n\t\t{\n\t\tGOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC,ERR_R_EC_LIB);\n\t\tgoto err;\n\t\t}\n\tif (!EC_KEY_set_public_key(ec,pub_key))\n\t\t{\n\t\tGOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC,ERR_R_EC_LIB);\n\t\tgoto err;\n\t\t}\n\tok = 256;\n\terr:\n\tBN_CTX_end(ctx);\n\tEC_POINT_free(pub_key);\n\tBN_CTX_free(ctx);\n\treturn ok;\n\t}', 'const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)\n\t{\n\treturn key->group;\n\t}', 'BN_CTX *BN_CTX_new(void)\n\t{\n\tBN_CTX *ret = OPENSSL_malloc(sizeof(BN_CTX));\n\tif(!ret)\n\t\t{\n\t\tBNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);\n\t\treturn NULL;\n\t\t}\n\tBN_POOL_init(&ret->pool);\n\tBN_STACK_init(&ret->stack);\n\tret->used = 0;\n\tret->err_stack = 0;\n\tret->too_many = 0;\n\treturn ret;\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}', '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}', 'void BN_CTX_start(BN_CTX *ctx)\n\t{\n\tCTXDBG_ENTRY("BN_CTX_start", ctx);\n\tif(ctx->err_stack || ctx->too_many)\n\t\tctx->err_stack++;\n\telse if(!BN_STACK_push(&ctx->stack, ctx->used))\n\t\t{\n\t\tBNerr(BN_F_BN_CTX_START,BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n\t\tctx->err_stack++;\n\t\t}\n\tCTXDBG_EXIT(ctx);\n\t}']