success. That means the iterator argument can't be const.
Rev: src/nettle/bignum.h:1.7
Rev: src/nettle/sexp2bignum.c:1.4
struct sexp_iterator;
-/* If LIMIT is non-zero, the number must be at most LIMIT bits. */
+/* If LIMIT is non-zero, the number must be at most LIMIT bits.
+ * Implies sexp_iterator_next. */
int
-nettle_mpz_set_sexp(mpz_t x, unsigned limit, const struct sexp_iterator *i);
+nettle_mpz_set_sexp(mpz_t x, unsigned limit, struct sexp_iterator *i);
#endif /* NETTLE_BIGNUM_H_INCLUDED */
#include "bignum.h"
int
-nettle_mpz_set_sexp(mpz_t x, unsigned limit, const struct sexp_iterator *i)
+nettle_mpz_set_sexp(mpz_t x, unsigned limit, struct sexp_iterator *i)
{
if (i->type == SEXP_ATOM
&& i->atom_length
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;
+ if (limit && mpz_sizeinbase(x, 2) > limit)
+ return 0;
+
+ return sexp_iterator_next(i);
}
else
return 0;