OPENSSL_SYS_WIN32 is important so util/mkdef.pl can detect it
[oweals/openssl.git] / crypto / bn / bn_div.c
index d0b68dc246e7c6d8f24242c1e0db9fa8d6b4be75..f9a095e3b3b4e13d2733865c9e1ed458387f354b 100644 (file)
@@ -130,7 +130,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
 #if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) \
     && !defined(PEDANTIC) && !defined(BN_DIV3W)
 # if defined(__GNUC__) && __GNUC__>=2
-#  if defined(__i386)
+#  if defined(__i386) || defined (__i386__)
    /*
     * There were two reasons for implementing this template:
     * - GNU C generates a call to a function (__udivdi3 to be exact)
@@ -200,10 +200,10 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
 
        /* First we normalise the numbers */
        norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);
-       BN_lshift(sdiv,divisor,norm_shift);
+       if (!(BN_lshift(sdiv,divisor,norm_shift))) goto err;
        sdiv->neg=0;
        norm_shift+=BN_BITS2;
-       BN_lshift(snum,num,norm_shift);
+       if (!(BN_lshift(snum,num,norm_shift))) goto err;
        snum->neg=0;
        div_n=sdiv->top;
        num_n=snum->top;
@@ -327,7 +327,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
                tmp->top=j;
 
                j=wnum.top;
-               BN_sub(&wnum,&wnum,tmp);
+               if (!BN_sub(&wnum,&wnum,tmp)) goto err;
 
                snum->top=snum->top+wnum.top-j;
 
@@ -335,7 +335,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
                        {
                        q--;
                        j=wnum.top;
-                       BN_add(&wnum,&wnum,sdiv);
+                       if (!BN_add(&wnum,&wnum,sdiv)) goto err;
                        snum->top+=wnum.top-j;
                        }
                *(resp--)=q;