]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - sshbn.c
Add FUZZING support to ssh.c.
[PuTTY.git] / sshbn.c
diff --git a/sshbn.c b/sshbn.c
index 3afea467f9d393fe55fa8f5581c4018665ebf5cd..7aa1069709f774964aa1de309fcb9f3412d528ef 100644 (file)
--- a/sshbn.c
+++ b/sshbn.c
@@ -1142,8 +1142,7 @@ Bignum bignum_from_bytes(const unsigned char *data, int nbytes)
             (BignumInt)byte << (8*i % BIGNUM_INT_BITS);
     }
 
-    while (result[0] > 1 && result[result[0]] == 0)
-       result[0]--;
+    bn_restore_invariant(result);
     return result;
 }
 
@@ -1165,8 +1164,7 @@ Bignum bignum_from_bytes_le(const unsigned char *data, int nbytes)
             (BignumInt)byte << (8*i % BIGNUM_INT_BITS);
     }
 
-    while (result[0] > 1 && result[result[0]] == 0)
-        result[0]--;
+    bn_restore_invariant(result);
     return result;
 }