crypto/rsa/rsa_saos.c:140: error: NULL_DEREFERENCE
  pointer `s` last assigned on line 117 could be null and is dereferenced by call to `memset()` at line 140, column 2.
Showing all 48 steps of the trace


crypto/rsa/rsa_saos.c:103:1: start of procedure RSA_verify_ASN1_OCTET_STRING()
101.   	}
102.   
103. > int RSA_verify_ASN1_OCTET_STRING(int dtype, unsigned char *m,
104.   	     unsigned int m_len, unsigned char *sigbuf, unsigned int siglen,
105.   	     RSA *rsa)

crypto/rsa/rsa_saos.c:107:2: 
105.   	     RSA *rsa)
106.   	{
107. > 	int i,ret=0;
108.   	unsigned char *p,*s;
109.   	ASN1_OCTET_STRING *sig=NULL;

crypto/rsa/rsa_saos.c:109:2: 
107.   	int i,ret=0;
108.   	unsigned char *p,*s;
109. > 	ASN1_OCTET_STRING *sig=NULL;
110.   
111.   	if (siglen != (unsigned int)RSA_size(rsa))

crypto/rsa/rsa_saos.c:111:6: 
109.   	ASN1_OCTET_STRING *sig=NULL;
110.   
111. > 	if (siglen != (unsigned int)RSA_size(rsa))
112.   		{
113.   		RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING,RSA_R_WRONG_SIGNATURE_LENGTH);

crypto/rsa/rsa_lib.c:212:1: start of procedure RSA_size()
  210.   	}
  211.   
  212. > int RSA_size(RSA *r)
  213.   	{
  214.   	return(BN_num_bytes(r->n));

crypto/rsa/rsa_lib.c:214:2: 
  212.   int RSA_size(RSA *r)
  213.   	{
  214. > 	return(BN_num_bytes(r->n));
  215.   	}
  216.   

crypto/bn/bn_lib.c:238:1: start of procedure BN_num_bits()
    236.   	}
    237.   
    238. > int BN_num_bits(const BIGNUM *a)
    239.   	{
    240.   	BN_ULONG l;

crypto/bn/bn_lib.c:245:6: Taking false branch
    243.   	bn_check_top(a);
    244.   
    245.   	if (a->top == 0) return(0);
                ^
    246.   	l=a->d[a->top-1];
    247.   	i=(a->top-1)*BN_BITS2;

crypto/bn/bn_lib.c:246:2: 
    244.   
    245.   	if (a->top == 0) return(0);
    246. > 	l=a->d[a->top-1];
    247.   	i=(a->top-1)*BN_BITS2;
    248.   	if (l == 0)

crypto/bn/bn_lib.c:247:2: 
    245.   	if (a->top == 0) return(0);
    246.   	l=a->d[a->top-1];
    247. > 	i=(a->top-1)*BN_BITS2;
    248.   	if (l == 0)
    249.   		{

crypto/bn/bn_lib.c:248:6: Taking false branch
    246.   	l=a->d[a->top-1];
    247.   	i=(a->top-1)*BN_BITS2;
    248.   	if (l == 0)
                ^
    249.   		{
    250.   #if !defined(NO_STDIO) && !defined(WIN16)

crypto/bn/bn_lib.c:255:2: Skipping BN_num_bits_word(): empty list of specs
    253.   		abort();
    254.   		}
    255.   	return(i+BN_num_bits_word(l));
            ^
    256.   	}
    257.   

crypto/bn/bn_lib.c:256:2: return from a call to BN_num_bits
    254.   		}
    255.   	return(i+BN_num_bits_word(l));
    256.   	}
            ^
    257.   
    258.   void BN_clear_free(BIGNUM *a)

crypto/rsa/rsa_lib.c:215:2: return from a call to RSA_size
  213.   	{
  214.   	return(BN_num_bytes(r->n));
  215.   	}
          ^
  216.   
  217.   int RSA_public_encrypt(int flen, unsigned char *from, unsigned char *to,

crypto/rsa/rsa_saos.c:111:6: Taking false branch
109.   	ASN1_OCTET_STRING *sig=NULL;
110.   
111.   	if (siglen != (unsigned int)RSA_size(rsa))
            ^
112.   		{
113.   		RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING,RSA_R_WRONG_SIGNATURE_LENGTH);

crypto/rsa/rsa_saos.c:117:2: 
115.   		}
116.   
117. > 	s=(unsigned char *)Malloc((unsigned int)siglen);
118.   	if (s == NULL)
119.   		{

crypto/mem.c:194:1: start of procedure CRYPTO_malloc()
  192.   	}
  193.   
  194. > void *CRYPTO_malloc(int num, char *file, int line)
  195.   	{
  196.   	char *ret = NULL;

crypto/mem.c:196:2: 
  194.   void *CRYPTO_malloc(int num, char *file, int line)
  195.   	{
  196. > 	char *ret = NULL;
  197.   
  198.   	allow_customize = 0;

crypto/mem.c:198:2: 
  196.   	char *ret = NULL;
  197.   
  198. > 	allow_customize = 0;
  199.   	if (malloc_debug_func != NULL)
  200.   		{

crypto/mem.c:199:6: Taking false branch
  197.   
  198.   	allow_customize = 0;
  199.   	if (malloc_debug_func != NULL)
              ^
  200.   		{
  201.   		allow_customize_debug = 0;

crypto/mem.c:204:2: Skipping __function_pointer__(): unresolved function pointer
  202.   		malloc_debug_func(NULL, num, file, line, 0);
  203.   		}
  204.   	ret = malloc_func(num);
          ^
  205.   #ifdef LEVITTE_DEBUG
  206.   	fprintf(stderr, "LEVITTE_DEBUG:         > 0x%p (%d)\n", ret, num);

crypto/mem.c:208:6: Taking false branch
  206.   	fprintf(stderr, "LEVITTE_DEBUG:         > 0x%p (%d)\n", ret, num);
  207.   #endif
  208.   	if (malloc_debug_func != NULL)
              ^
  209.   		malloc_debug_func(ret, num, file, line, 1);
  210.   

crypto/mem.c:211:2: 
  209.   		malloc_debug_func(ret, num, file, line, 1);
  210.   
  211. > 	return ret;
  212.   	}
  213.   

crypto/mem.c:212:2: return from a call to CRYPTO_malloc
  210.   
  211.   	return ret;
  212.   	}
          ^
  213.   
  214.   void *CRYPTO_realloc(void *str, int num, char *file, int line)

crypto/rsa/rsa_saos.c:118:6: Taking true branch
116.   
117.   	s=(unsigned char *)Malloc((unsigned int)siglen);
118.   	if (s == NULL)
            ^
119.   		{
120.   		RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE);

crypto/rsa/rsa_saos.c:120:3: 
118.   	if (s == NULL)
119.   		{
120. > 		RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE);
121.   		goto err;
122.   		}

crypto/err/err.c:245:1: start of procedure ERR_put_error()
  243.   /********************************************************/
  244.   
  245. > void ERR_put_error(int lib, int func, int reason, const char *file,
  246.   	     int line)
  247.   	{

crypto/err/err.c:269:2: Skipping ERR_get_state(): empty list of specs
  267.   	}
  268.   #endif
  269.   	es=ERR_get_state();
          ^
  270.   
  271.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:271:2: 
  269.   	es=ERR_get_state();
  270.   
  271. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
  272.   	if (es->top == es->bottom)
  273.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:272:6: Taking false branch
  270.   
  271.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
  272.   	if (es->top == es->bottom)
              ^
  273.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
  274.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);

crypto/err/err.c:274:2: 
  272.   	if (es->top == es->bottom)
  273.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
  274. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
  275.   	es->err_file[es->top]=file;
  276.   	es->err_line[es->top]=line;

crypto/err/err.c:275:2: 
  273.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
  274.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
  275. > 	es->err_file[es->top]=file;
  276.   	es->err_line[es->top]=line;
  277.   	err_clear_data(es,es->top);

crypto/err/err.c:276:2: 
  274.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
  275.   	es->err_file[es->top]=file;
  276. > 	es->err_line[es->top]=line;
  277.   	err_clear_data(es,es->top);
  278.   	}

crypto/err/err.c:277:2: Taking true branch
  275.   	es->err_file[es->top]=file;
  276.   	es->err_line[es->top]=line;
  277.   	err_clear_data(es,es->top);
          ^
  278.   	}
  279.   

crypto/err/err.c:277:2: Taking true branch
  275.   	es->err_file[es->top]=file;
  276.   	es->err_line[es->top]=line;
  277.   	err_clear_data(es,es->top);
          ^
  278.   	}
  279.   

crypto/mem.c:230:1: start of procedure CRYPTO_free()
    228.   	}
    229.   
    230. > void CRYPTO_free(void *str)
    231.   	{
    232.   	if (free_debug_func != NULL)

crypto/mem.c:232:6: Taking true branch
    230.   void CRYPTO_free(void *str)
    231.   	{
    232.   	if (free_debug_func != NULL)
                ^
    233.   		free_debug_func(str, 0);
    234.   #ifdef LEVITTE_DEBUG

crypto/mem.c:233:3: Skipping __function_pointer__(): unresolved function pointer
    231.   	{
    232.   	if (free_debug_func != NULL)
    233.   		free_debug_func(str, 0);
             ^
    234.   #ifdef LEVITTE_DEBUG
    235.   	fprintf(stderr, "LEVITTE_DEBUG:         < 0x%p\n", str);

crypto/mem.c:237:2: Skipping __function_pointer__(): unresolved function pointer
    235.   	fprintf(stderr, "LEVITTE_DEBUG:         < 0x%p\n", str);
    236.   #endif
    237.   	free_func(str);
            ^
    238.   	if (free_debug_func != NULL)
    239.   		free_debug_func(NULL, 1);

crypto/mem.c:238:6: Taking true branch
    236.   #endif
    237.   	free_func(str);
    238.   	if (free_debug_func != NULL)
                ^
    239.   		free_debug_func(NULL, 1);
    240.   	}

crypto/mem.c:239:3: Skipping __function_pointer__(): unresolved function pointer
    237.   	free_func(str);
    238.   	if (free_debug_func != NULL)
    239.   		free_debug_func(NULL, 1);
             ^
    240.   	}
    241.   

crypto/mem.c:238:2: 
    236.   #endif
    237.   	free_func(str);
    238. > 	if (free_debug_func != NULL)
    239.   		free_debug_func(NULL, 1);
    240.   	}

crypto/mem.c:240:2: return from a call to CRYPTO_free
    238.   	if (free_debug_func != NULL)
    239.   		free_debug_func(NULL, 1);
    240.   	}
            ^
    241.   
    242.   void *CRYPTO_remalloc(void *a, int num, char *file, int line)

crypto/err/err.c:277:2: 
  275.   	es->err_file[es->top]=file;
  276.   	es->err_line[es->top]=line;
  277. > 	err_clear_data(es,es->top);
  278.   	}
  279.   

crypto/err/err.c:278:2: return from a call to ERR_put_error
  276.   	es->err_line[es->top]=line;
  277.   	err_clear_data(es,es->top);
  278.   	}
          ^
  279.   
  280.   void ERR_clear_error(void)

crypto/rsa/rsa_saos.c:138:1: 
136.   	else
137.   		ret=1;
138. > err:
139.   	if (sig != NULL) M_ASN1_OCTET_STRING_free(sig);
140.   	memset(s,0,(unsigned int)siglen);

crypto/rsa/rsa_saos.c:139:6: Taking false branch
137.   		ret=1;
138.   err:
139.   	if (sig != NULL) M_ASN1_OCTET_STRING_free(sig);
            ^
140.   	memset(s,0,(unsigned int)siglen);
141.   	Free(s);

crypto/rsa/rsa_saos.c:140:2: 
138.   err:
139.   	if (sig != NULL) M_ASN1_OCTET_STRING_free(sig);
140. > 	memset(s,0,(unsigned int)siglen);
141.   	Free(s);
142.   	return(ret);

int RSA_verify_ASN1_OCTET_STRING(int dtype, unsigned char *m,
	     unsigned int m_len, unsigned char *sigbuf, unsigned int siglen,
	     RSA *rsa)
	{
	int i,ret=0;
	unsigned char *p,*s;
	ASN1_OCTET_STRING *sig=NULL;
	if (siglen != (unsigned int)RSA_size(rsa))
		{
		RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING,RSA_R_WRONG_SIGNATURE_LENGTH);
		return(0);
		}
	s=(unsigned char *)Malloc((unsigned int)siglen);
	if (s == NULL)
		{
		RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE);
		goto err;
		}
	i=RSA_public_decrypt((int)siglen,sigbuf,s,rsa,RSA_PKCS1_PADDING);
	if (i <= 0) goto err;
	p=s;
	sig=d2i_ASN1_OCTET_STRING(NULL,&p,(long)i);
	if (sig == NULL) goto err;
	if (	((unsigned int)sig->length != m_len) ||
		(memcmp(m,sig->data,m_len) != 0))
		{
		RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING,RSA_R_BAD_SIGNATURE);
		}
	else
		ret=1;
err:
	if (sig != NULL) M_ASN1_OCTET_STRING_free(sig);
	memset(s,0,(unsigned int)siglen);
	Free(s);
	return(ret);
	}
['int RSA_verify_ASN1_OCTET_STRING(int dtype, unsigned char *m,\n\t     unsigned int m_len, unsigned char *sigbuf, unsigned int siglen,\n\t     RSA *rsa)\n\t{\n\tint i,ret=0;\n\tunsigned char *p,*s;\n\tASN1_OCTET_STRING *sig=NULL;\n\tif (siglen != (unsigned int)RSA_size(rsa))\n\t\t{\n\t\tRSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING,RSA_R_WRONG_SIGNATURE_LENGTH);\n\t\treturn(0);\n\t\t}\n\ts=(unsigned char *)Malloc((unsigned int)siglen);\n\tif (s == NULL)\n\t\t{\n\t\tRSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\ti=RSA_public_decrypt((int)siglen,sigbuf,s,rsa,RSA_PKCS1_PADDING);\n\tif (i <= 0) goto err;\n\tp=s;\n\tsig=d2i_ASN1_OCTET_STRING(NULL,&p,(long)i);\n\tif (sig == NULL) goto err;\n\tif (\t((unsigned int)sig->length != m_len) ||\n\t\t(memcmp(m,sig->data,m_len) != 0))\n\t\t{\n\t\tRSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING,RSA_R_BAD_SIGNATURE);\n\t\t}\n\telse\n\t\tret=1;\nerr:\n\tif (sig != NULL) M_ASN1_OCTET_STRING_free(sig);\n\tmemset(s,0,(unsigned int)siglen);\n\tFree(s);\n\treturn(ret);\n\t}', 'int RSA_size(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\ti=(a->top-1)*BN_BITS2;\n\tif (l == 0)\n\t\t{\n#if !defined(NO_STDIO) && !defined(WIN16)\n\t\tfprintf(stderr,"BAD TOP VALUE\\n");\n#endif\n\t\tabort();\n\t\t}\n\treturn(i+BN_num_bits_word(l));\n\t}', 'void *CRYPTO_malloc(int num, char *file, int line)\n\t{\n\tchar *ret = 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_func(num);\n#ifdef LEVITTE_DEBUG\n\tfprintf(stderr, "LEVITTE_DEBUG:         > 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\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_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 CRYPTO_free(void *str)\n\t{\n\tif (free_debug_func != NULL)\n\t\tfree_debug_func(str, 0);\n#ifdef LEVITTE_DEBUG\n\tfprintf(stderr, "LEVITTE_DEBUG:         < 0x%p\\n", str);\n#endif\n\tfree_func(str);\n\tif (free_debug_func != NULL)\n\t\tfree_debug_func(NULL, 1);\n\t}']