When BN_add_word() reaches top, it shouldn't try to add the the corresponding
authorRichard Levitte <levitte@openssl.org>
Mon, 14 Oct 2002 11:33:32 +0000 (11:33 +0000)
committerRichard Levitte <levitte@openssl.org>
Mon, 14 Oct 2002 11:33:32 +0000 (11:33 +0000)
word, since that word may not be zero.

crypto/bn/bn_word.c

index cd59baa..988e0ca 100644 (file)
@@ -123,7 +123,10 @@ int BN_add_word(BIGNUM *a, BN_ULONG w)
        i=0;
        for (;;)
                {
        i=0;
        for (;;)
                {
-               l=(a->d[i]+(BN_ULONG)w)&BN_MASK2;
+               if (i >= a->top)
+                       l=w;
+               else
+                       l=(a->d[i]+(BN_ULONG)w)&BN_MASK2;
                a->d[i]=l;
                if (w > l)
                        w=1;
                a->d[i]=l;
                if (w > l)
                        w=1;