Skip to content
Snippets Groups Projects
Commit 093e19c0 authored by Niels Möller's avatar Niels Möller
Browse files

(nettle_mpz_set_sexp): In the first check against

limit, added some margin to allow for sign octets.

Rev: src/nettle/sexp2bignum.c:1.3
parent 136c422d
No related branches found
No related tags found
No related merge requests found
...@@ -38,10 +38,12 @@ nettle_mpz_set_sexp(mpz_t x, unsigned limit, const struct sexp_iterator *i) ...@@ -38,10 +38,12 @@ nettle_mpz_set_sexp(mpz_t x, unsigned limit, const struct sexp_iterator *i)
&& i->atom_length && i->atom_length
&& !i->display) && !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; return 0;
nettle_mpz_set_str_256_s(x, i->atom_length, i->atom); 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; return !limit || mpz_sizeinbase(x, 2) <= limit;
} }
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment