crypto/bn/bn_nist.c:509: error: INTEGER_OVERFLOW_L2
  (0 - [0, 2]):unsigned64.
Showing all 5 steps of the trace


crypto/bn/bn_nist.c:508:11: <RHS trace>
506.   	else if (carry < 0)
507.   		{
508.   		carry = bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP);
                 ^
509.   		mask = 0-(size_t)carry;
510.   		u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask);

crypto/bn/bn_nist.c:508:11: Call
506.   	else if (carry < 0)
507.   		{
508.   		carry = bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP);
                 ^
509.   		mask = 0-(size_t)carry;
510.   		u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask);

crypto/bn/bn_asm.c:346:14: Assignment
  344.   
  345.   	assert(n >= 0);
  346.   	if (n <= 0) return((BN_ULONG)0);
                      ^
  347.   
  348.   	c=0;

crypto/bn/bn_nist.c:508:3: Assignment
506.   	else if (carry < 0)
507.   		{
508.   		carry = bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP);
         ^
509.   		mask = 0-(size_t)carry;
510.   		u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask);

crypto/bn/bn_nist.c:509:3: Binary operation: (0 - [0, 2]):unsigned64
507.   		{
508.   		carry = bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP);
509.   		mask = 0-(size_t)carry;
         ^
510.   		u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask);
511.   		}

int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
	BN_CTX *ctx)
	{
	int	i, top = a->top;
	int	carry = 0;
	register BN_ULONG *a_d = a->d, *r_d;
	BN_ULONG t_d[BN_NIST_256_TOP],
	         buf[BN_NIST_256_TOP],
		 c_d[BN_NIST_256_TOP],
		*res;
	size_t   mask;
	union { bn_addsub_f f; size_t p; } u;
	i = BN_ucmp(field, a);
	if (i == 0)
		{
		BN_zero(r);
		return 1;
		}
	else if (i > 0)
		return (r == a)? 1 : (BN_copy(r ,a) != NULL);
	if (top == BN_NIST_256_TOP)
		return BN_usub(r, a, field);
	if (r != a)
		{
		if (!bn_wexpand(r, BN_NIST_256_TOP))
			return 0;
		r_d = r->d;
		nist_cp_bn(r_d, a_d, BN_NIST_256_TOP);
		}
	else
		r_d = a_d;
	nist_cp_bn_0(buf, a_d + BN_NIST_256_TOP, top - BN_NIST_256_TOP, BN_NIST_256_TOP);
	nist_set_256(t_d, buf, 15, 14, 13, 12, 11, 0, 0, 0);
	nist_set_256(c_d, buf, 0, 15, 14, 13, 12, 0, 0, 0);
	carry = bn_add_words(t_d, t_d, c_d, BN_NIST_256_TOP);
		{
		register BN_ULONG *ap,t,c;
		ap = t_d;
		c=0;
		for (i = BN_NIST_256_TOP; i != 0; --i)
			{
			t= *ap;
			*(ap++)=((t<<1)|c)&BN_MASK2;
			c=(t & BN_TBIT)?1:0;
			}
		carry <<= 1;
		carry  |= c;
		}
	carry += bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP);
	nist_set_256(t_d, buf, 15, 14, 0, 0, 0, 10, 9, 8);
	carry += bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP);
	nist_set_256(t_d, buf, 8, 13, 15, 14, 13, 11, 10, 9);
	carry += bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP);
	nist_set_256(t_d, buf, 10, 8, 0, 0, 0, 13, 12, 11);
	carry -= bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);
	nist_set_256(t_d, buf, 11, 9, 0, 0, 15, 14, 13, 12);
	carry -= bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);
	nist_set_256(t_d, buf, 12, 0, 10, 9, 8, 15, 14, 13);
	carry -= bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);
	nist_set_256(t_d, buf, 13, 0, 11, 10, 9, 0, 15, 14);
	carry -= bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);
	u.f = bn_sub_words;
	if (carry > 0)
		carry = bn_sub_words(r_d,r_d,_nist_p_256[carry-1],BN_NIST_256_TOP);
	else if (carry < 0)
		{
		carry = bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP);
		mask = 0-(size_t)carry;
		u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask);
		}
	else
		carry = 1;
	mask  = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP);
	mask &= 0-(size_t)carry;
	res   = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask));
	nist_cp_bn(r_d, res, BN_NIST_256_TOP);
	r->top = BN_NIST_256_TOP;
	bn_correct_top(r);
	return 1;
	}
['int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,\n\tBN_CTX *ctx)\n\t{\n\tint\ti, top = a->top;\n\tint\tcarry = 0;\n\tregister BN_ULONG *a_d = a->d, *r_d;\n\tBN_ULONG t_d[BN_NIST_256_TOP],\n\t         buf[BN_NIST_256_TOP],\n\t\t c_d[BN_NIST_256_TOP],\n\t\t*res;\n\tsize_t   mask;\n\tunion { bn_addsub_f f; size_t p; } u;\n\ti = BN_ucmp(field, a);\n\tif (i == 0)\n\t\t{\n\t\tBN_zero(r);\n\t\treturn 1;\n\t\t}\n\telse if (i > 0)\n\t\treturn (r == a)? 1 : (BN_copy(r ,a) != NULL);\n\tif (top == BN_NIST_256_TOP)\n\t\treturn BN_usub(r, a, field);\n\tif (r != a)\n\t\t{\n\t\tif (!bn_wexpand(r, BN_NIST_256_TOP))\n\t\t\treturn 0;\n\t\tr_d = r->d;\n\t\tnist_cp_bn(r_d, a_d, BN_NIST_256_TOP);\n\t\t}\n\telse\n\t\tr_d = a_d;\n\tnist_cp_bn_0(buf, a_d + BN_NIST_256_TOP, top - BN_NIST_256_TOP, BN_NIST_256_TOP);\n\tnist_set_256(t_d, buf, 15, 14, 13, 12, 11, 0, 0, 0);\n\tnist_set_256(c_d, buf, 0, 15, 14, 13, 12, 0, 0, 0);\n\tcarry = bn_add_words(t_d, t_d, c_d, BN_NIST_256_TOP);\n\t\t{\n\t\tregister BN_ULONG *ap,t,c;\n\t\tap = t_d;\n\t\tc=0;\n\t\tfor (i = BN_NIST_256_TOP; i != 0; --i)\n\t\t\t{\n\t\t\tt= *ap;\n\t\t\t*(ap++)=((t<<1)|c)&BN_MASK2;\n\t\t\tc=(t & BN_TBIT)?1:0;\n\t\t\t}\n\t\tcarry <<= 1;\n\t\tcarry  |= c;\n\t\t}\n\tcarry += bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n\tnist_set_256(t_d, buf, 15, 14, 0, 0, 0, 10, 9, 8);\n\tcarry += bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n\tnist_set_256(t_d, buf, 8, 13, 15, 14, 13, 11, 10, 9);\n\tcarry += bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n\tnist_set_256(t_d, buf, 10, 8, 0, 0, 0, 13, 12, 11);\n\tcarry -= bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n\tnist_set_256(t_d, buf, 11, 9, 0, 0, 15, 14, 13, 12);\n\tcarry -= bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n\tnist_set_256(t_d, buf, 12, 0, 10, 9, 8, 15, 14, 13);\n\tcarry -= bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n\tnist_set_256(t_d, buf, 13, 0, 11, 10, 9, 0, 15, 14);\n\tcarry -= bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n\tu.f = bn_sub_words;\n\tif (carry > 0)\n\t\tcarry = bn_sub_words(r_d,r_d,_nist_p_256[carry-1],BN_NIST_256_TOP);\n\telse if (carry < 0)\n\t\t{\n\t\tcarry = bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP);\n\t\tmask = 0-(size_t)carry;\n\t\tu.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask);\n\t\t}\n\telse\n\t\tcarry = 1;\n\tmask  = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP);\n\tmask &= 0-(size_t)carry;\n\tres   = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask));\n\tnist_cp_bn(r_d, res, BN_NIST_256_TOP);\n\tr->top = BN_NIST_256_TOP;\n\tbn_correct_top(r);\n\treturn 1;\n\t}', 'BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)\n        {\n\tBN_ULONG c,l,t;\n\tassert(n >= 0);\n\tif (n <= 0) return((BN_ULONG)0);\n\tc=0;\n#ifndef OPENSSL_SMALL_FOOTPRINT\n\twhile (n&~3)\n\t\t{\n\t\tt=a[0];\n\t\tt=(t+c)&BN_MASK2;\n\t\tc=(t < c);\n\t\tl=(t+b[0])&BN_MASK2;\n\t\tc+=(l < t);\n\t\tr[0]=l;\n\t\tt=a[1];\n\t\tt=(t+c)&BN_MASK2;\n\t\tc=(t < c);\n\t\tl=(t+b[1])&BN_MASK2;\n\t\tc+=(l < t);\n\t\tr[1]=l;\n\t\tt=a[2];\n\t\tt=(t+c)&BN_MASK2;\n\t\tc=(t < c);\n\t\tl=(t+b[2])&BN_MASK2;\n\t\tc+=(l < t);\n\t\tr[2]=l;\n\t\tt=a[3];\n\t\tt=(t+c)&BN_MASK2;\n\t\tc=(t < c);\n\t\tl=(t+b[3])&BN_MASK2;\n\t\tc+=(l < t);\n\t\tr[3]=l;\n\t\ta+=4; b+=4; r+=4; n-=4;\n\t\t}\n#endif\n\twhile(n)\n\t\t{\n\t\tt=a[0];\n\t\tt=(t+c)&BN_MASK2;\n\t\tc=(t < c);\n\t\tl=(t+b[0])&BN_MASK2;\n\t\tc+=(l < t);\n\t\tr[0]=l;\n\t\ta++; b++; r++; n--;\n\t\t}\n\treturn((BN_ULONG)c);\n\t}']