Don't use assertions to check application-provided arguments;
[oweals/openssl.git] / crypto / bn / bn_gf2m.c
index 2af6540ff30fcbb5ac7051a8f1bafd004241f1b5..306f029f2789c907c6fcc949a760622f6b977aa8 100644 (file)
@@ -384,7 +384,11 @@ int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[])
                if (zz == 0) break;
                d1 = BN_BITS2 - d0;
                
-               if (d0) z[dN] = (z[dN] << d1) >> d1; /* clear up the top d1 bits */
+               /* clear up the top d1 bits */
+               if (d0)
+                       z[dN] = (z[dN] << d1) >> d1;
+               else
+                       z[dN] = 0;
                z[0] ^= zz; /* reduction t^0 component */
 
                for (k = 1; p[k] != 0; k++)
@@ -1080,7 +1084,8 @@ int BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a)
        BN_zero(a);
        for (i = 0; p[i] != 0; i++)
                {
-               BN_set_bit(a, p[i]);
+               if (BN_set_bit(a, p[i]) == 0)
+                       return 0;
                }
        BN_set_bit(a, 0);
        bn_check_top(a);