engines/ccgost/gost_ameth.c:424: error: NULL_DEREFERENCE
  pointer `ctx` last assigned on line 420 could be null and is dereferenced by call to `BN_CTX_start()` at line 424, column 3.
Showing all 39 steps of the trace


engines/ccgost/gost_ameth.c:401:1: start of procedure print_gost_01()
399.   	}
400.   
401. > static int print_gost_01(BIO *out, const EVP_PKEY *pkey, int indent,
402.   	ASN1_PCTX *pctx, int type)
403.   	{

engines/ccgost/gost_ameth.c:404:2: 
402.   	ASN1_PCTX *pctx, int type)
403.   	{
404. > 	int param_nid = NID_undef;
405.   	if (type == 2) 
406.   		{

engines/ccgost/gost_ameth.c:405:6: Taking false branch
403.   	{
404.   	int param_nid = NID_undef;
405.   	if (type == 2) 
            ^
406.   		{
407.   		BIGNUM *key;

engines/ccgost/gost_ameth.c:418:6: Taking true branch
416.   		BIO_printf(out,"\n");
417.   		}
418.   	if (type >=1) 
            ^
419.   		{
420.   		BN_CTX *ctx = BN_CTX_new();

engines/ccgost/gost_ameth.c:420:3: 
418.   	if (type >=1) 
419.   		{
420. > 		BN_CTX *ctx = BN_CTX_new();
421.   		BIGNUM *X,*Y;
422.   		const EC_POINT *pubkey;

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:294:1: start of procedure CRYPTO_malloc()
    292.   	}
    293.   
    294. > void *CRYPTO_malloc(int num, const char *file, int line)
    295.   	{
    296.   	void *ret = NULL;

crypto/mem.c:296:2: 
    294.   void *CRYPTO_malloc(int num, const char *file, int line)
    295.   	{
    296. > 	void *ret = NULL;
    297.   
    298.   	if (num <= 0) return NULL;

crypto/mem.c:298:6: Taking false branch
    296.   	void *ret = NULL;
    297.   
    298.   	if (num <= 0) return NULL;
                ^
    299.   
    300.   	allow_customize = 0;

crypto/mem.c:300:2: 
    298.   	if (num <= 0) return NULL;
    299.   
    300. > 	allow_customize = 0;
    301.   	if (malloc_debug_func != NULL)
    302.   		{

crypto/mem.c:301:6: Taking true branch
    299.   
    300.   	allow_customize = 0;
    301.   	if (malloc_debug_func != NULL)
                ^
    302.   		{
    303.   		allow_customize_debug = 0;

crypto/mem.c:303:3: 
    301.   	if (malloc_debug_func != NULL)
    302.   		{
    303. > 		allow_customize_debug = 0;
    304.   		malloc_debug_func(NULL, num, file, line, 0);
    305.   		}

crypto/mem.c:304:3: Skipping __function_pointer__(): unresolved function pointer
    302.   		{
    303.   		allow_customize_debug = 0;
    304.   		malloc_debug_func(NULL, num, file, line, 0);
             ^
    305.   		}
    306.   	ret = malloc_ex_func(num,file,line);

crypto/mem.c:306:2: Skipping __function_pointer__(): unresolved function pointer
    304.   		malloc_debug_func(NULL, num, file, line, 0);
    305.   		}
    306.   	ret = malloc_ex_func(num,file,line);
            ^
    307.   #ifdef LEVITTE_DEBUG_MEM
    308.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);

crypto/mem.c:310:6: Taking true branch
    308.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
    309.   #endif
    310.   	if (malloc_debug_func != NULL)
                ^
    311.   		malloc_debug_func(ret, num, file, line, 1);
    312.   

crypto/mem.c:311:3: Skipping __function_pointer__(): unresolved function pointer
    309.   #endif
    310.   	if (malloc_debug_func != NULL)
    311.   		malloc_debug_func(ret, num, file, line, 1);
             ^
    312.   
    313.   #ifndef OPENSSL_CPUID_OBJ

crypto/mem.c:317:12: Taking false branch
    315.            * sanitisation function can't be optimised out. NB: We only do
    316.            * this for >2Kb so the overhead doesn't bother us. */
    317.           if(ret && (num > 2048))
                      ^
    318.   	{	extern unsigned char cleanse_ctr;
    319.                   ((unsigned char *)ret)[0] = cleanse_ctr;

crypto/mem.c:323:2: 
    321.   #endif
    322.   
    323. > 	return ret;
    324.   	}
    325.   

crypto/mem.c:324:2: return from a call to CRYPTO_malloc
    322.   
    323.   	return ret;
    324.   	}
            ^
    325.   
    326.   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:706:1: start of procedure ERR_put_error()
    704.   /********************************************************/
    705.   
    706. > void ERR_put_error(int lib, int func, int reason, const char *file,
    707.   	     int line)
    708.   	{

crypto/err/err.c:730:2: Skipping ERR_get_state(): empty list of specs
    728.   	}
    729.   #endif
    730.   	es=ERR_get_state();
            ^
    731.   
    732.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:732:2: 
    730.   	es=ERR_get_state();
    731.   
    732. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
    733.   	if (es->top == es->bottom)
    734.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:733:6: Taking false branch
    731.   
    732.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
    733.   	if (es->top == es->bottom)
                ^
    734.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    735.   	es->err_flags[es->top]=0;

crypto/err/err.c:735:2: 
    733.   	if (es->top == es->bottom)
    734.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    735. > 	es->err_flags[es->top]=0;
    736.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    737.   	es->err_file[es->top]=file;

crypto/err/err.c:736:2: 
    734.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
    735.   	es->err_flags[es->top]=0;
    736. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    737.   	es->err_file[es->top]=file;
    738.   	es->err_line[es->top]=line;

crypto/err/err.c:737:2: 
    735.   	es->err_flags[es->top]=0;
    736.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    737. > 	es->err_file[es->top]=file;
    738.   	es->err_line[es->top]=line;
    739.   	err_clear_data(es,es->top);

crypto/err/err.c:738:2: 
    736.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
    737.   	es->err_file[es->top]=file;
    738. > 	es->err_line[es->top]=line;
    739.   	err_clear_data(es,es->top);
    740.   	}

crypto/err/err.c:739:2: Taking true branch
    737.   	es->err_file[es->top]=file;
    738.   	es->err_line[es->top]=line;
    739.   	err_clear_data(es,es->top);
            ^
    740.   	}
    741.   

crypto/err/err.c:739:2: Taking false branch
    737.   	es->err_file[es->top]=file;
    738.   	es->err_line[es->top]=line;
    739.   	err_clear_data(es,es->top);
            ^
    740.   	}
    741.   

crypto/err/err.c:739:2: Loop condition is false. Leaving loop
    737.   	es->err_file[es->top]=file;
    738.   	es->err_line[es->top]=line;
    739.   	err_clear_data(es,es->top);
            ^
    740.   	}
    741.   

crypto/err/err.c:740:2: return from a call to ERR_put_error
    738.   	es->err_line[es->top]=line;
    739.   	err_clear_data(es,es->top);
    740.   	}
            ^
    741.   
    742.   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/gost_ameth.c:424:3: 
422.   		const EC_POINT *pubkey;
423.   		const EC_GROUP *group;
424. > 		BN_CTX_start(ctx);
425.   		X= BN_CTX_get(ctx);
426.   		Y=BN_CTX_get(ctx);

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 */

static int print_gost_01(BIO *out, const EVP_PKEY *pkey, int indent,
	ASN1_PCTX *pctx, int type)
	{
	int param_nid = NID_undef;
	if (type == 2)
		{
		BIGNUM *key;
		if (!BIO_indent(out,indent,128)) return 0;
		BIO_printf(out,"Private key: ");
		key = gost_get0_priv_key(pkey);
		if (!key)
			BIO_printf(out,"<undefined)");
		else
			BN_print(out,key);
		BIO_printf(out,"\n");
		}
	if (type >=1)
		{
		BN_CTX *ctx = BN_CTX_new();
		BIGNUM *X,*Y;
		const EC_POINT *pubkey;
		const EC_GROUP *group;
		BN_CTX_start(ctx);
		X= BN_CTX_get(ctx);
		Y=BN_CTX_get(ctx);
		if (!ctx)
			{
			GOSTerr(GOST_F_PRINT_GOST_01,ERR_R_MALLOC_FAILURE);
			return 0;
			}
		pubkey = EC_KEY_get0_public_key((EC_KEY *)EVP_PKEY_get0((EVP_PKEY *)pkey));
		group = EC_KEY_get0_group((EC_KEY *)EVP_PKEY_get0((EVP_PKEY *)pkey));
		if (!EC_POINT_get_affine_coordinates_GFp(group,pubkey,X,Y,ctx))
			{
			GOSTerr(GOST_F_PRINT_GOST_01,ERR_R_EC_LIB);
			BN_CTX_free(ctx);
			return 0;
			}
		if (!BIO_indent(out,indent,128)) return 0;
		BIO_printf(out,"Public key:\n");
		if (!BIO_indent(out,indent+3,128)) return 0;
		BIO_printf(out,"X:");
		BN_print(out,X);
		BIO_printf(out,"\n");
		BIO_indent(out,indent+3,128);
		BIO_printf(out,"Y:");
		BN_print(out,Y);
		BIO_printf(out,"\n");
		BN_CTX_end(ctx);
		BN_CTX_free(ctx);
		}
	param_nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(EVP_PKEY_get0((EVP_PKEY *)pkey)));
	if (!BIO_indent(out,indent,128)) return 0;
	BIO_printf(out,"Parameter set: %s\n",OBJ_nid2ln(param_nid));
	return 1;
}
['static int print_gost_01(BIO *out, const EVP_PKEY *pkey, int indent,\n\tASN1_PCTX *pctx, int type)\n\t{\n\tint param_nid = NID_undef;\n\tif (type == 2)\n\t\t{\n\t\tBIGNUM *key;\n\t\tif (!BIO_indent(out,indent,128)) return 0;\n\t\tBIO_printf(out,"Private key: ");\n\t\tkey = gost_get0_priv_key(pkey);\n\t\tif (!key)\n\t\t\tBIO_printf(out,"<undefined)");\n\t\telse\n\t\t\tBN_print(out,key);\n\t\tBIO_printf(out,"\\n");\n\t\t}\n\tif (type >=1)\n\t\t{\n\t\tBN_CTX *ctx = BN_CTX_new();\n\t\tBIGNUM *X,*Y;\n\t\tconst EC_POINT *pubkey;\n\t\tconst EC_GROUP *group;\n\t\tBN_CTX_start(ctx);\n\t\tX= BN_CTX_get(ctx);\n\t\tY=BN_CTX_get(ctx);\n\t\tif (!ctx)\n\t\t\t{\n\t\t\tGOSTerr(GOST_F_PRINT_GOST_01,ERR_R_MALLOC_FAILURE);\n\t\t\treturn 0;\n\t\t\t}\n\t\tpubkey = EC_KEY_get0_public_key((EC_KEY *)EVP_PKEY_get0((EVP_PKEY *)pkey));\n\t\tgroup = EC_KEY_get0_group((EC_KEY *)EVP_PKEY_get0((EVP_PKEY *)pkey));\n\t\tif (!EC_POINT_get_affine_coordinates_GFp(group,pubkey,X,Y,ctx))\n\t\t\t{\n\t\t\tGOSTerr(GOST_F_PRINT_GOST_01,ERR_R_EC_LIB);\n\t\t\tBN_CTX_free(ctx);\n\t\t\treturn 0;\n\t\t\t}\n\t\tif (!BIO_indent(out,indent,128)) return 0;\n\t\tBIO_printf(out,"Public key:\\n");\n\t\tif (!BIO_indent(out,indent+3,128)) return 0;\n\t\tBIO_printf(out,"X:");\n\t\tBN_print(out,X);\n\t\tBIO_printf(out,"\\n");\n\t\tBIO_indent(out,indent+3,128);\n\t\tBIO_printf(out,"Y:");\n\t\tBN_print(out,Y);\n\t\tBIO_printf(out,"\\n");\n\t\tBN_CTX_end(ctx);\n\t\tBN_CTX_free(ctx);\n\t\t}\n\tparam_nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(EVP_PKEY_get0((EVP_PKEY *)pkey)));\n\tif (!BIO_indent(out,indent,128)) return 0;\n\tBIO_printf(out,"Parameter set: %s\\n",OBJ_nid2ln(param_nid));\n\treturn 1;\n}', '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\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#ifndef OPENSSL_CPUID_OBJ\n        if(ret && (num > 2048))\n\t{\textern unsigned char cleanse_ctr;\n                ((unsigned char *)ret)[0] = cleanse_ctr;\n\t}\n#endif\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}']