]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
(nettle_mpz_set_sexp): In the first check against
authorNiels Möller <nisse@lysator.liu.se>
Fri, 15 Nov 2002 23:23:04 +0000 (00:23 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Fri, 15 Nov 2002 23:23:04 +0000 (00:23 +0100)
limit, added some margin to allow for sign octets.

Rev: src/nettle/sexp2bignum.c:1.3

sexp2bignum.c

index 69757cee98ffa7b09e377368f6b1faabcb55c1e1..f7ef68843f9feb6003c403d01776234503442578 100644 (file)
@@ -38,10 +38,12 @@ nettle_mpz_set_sexp(mpz_t x, unsigned limit, const struct sexp_iterator *i)
       && i->atom_length
       && !i->display)
     {
-      if (limit && (8 * i->atom_length > limit))
+      /* Allow some extra here, for leading sign octets. */
+      if (limit && (8 * i->atom_length > (16 + limit)))
        return 0;
       
       nettle_mpz_set_str_256_s(x, i->atom_length, i->atom);
+      /* FIXME: How to interpret a limit for negative numbers? */
       return !limit || mpz_sizeinbase(x, 2) <= limit;
     }
   else