From 01d4fd84ac24d20f8ebd8f16374f97373c1fc104 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Fri, 18 Oct 2019 21:24:23 +0100 Subject: [PATCH] catacomb.c, ec.c, group.c, mp.c: Count base/exponent pairs with `size_t'. Admittedly, if you get even slightly close to the limits of an `int', the calculation will take an infinite amount of time. --- catacomb-python.h | 2 +- catacomb.c | 5 +++-- ec.c | 2 +- group.c | 2 +- mp.c | 6 +++--- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/catacomb-python.h b/catacomb-python.h index aa55cc5..6128cc8 100644 --- a/catacomb-python.h +++ b/catacomb-python.h @@ -151,7 +151,7 @@ extern PyObject *mexp_common(PyObject *, PyObject *, size_t, PyObject *(*id)(PyObject *), int (*fill)(void *, PyObject *, PyObject *, PyObject *), - PyObject *(*exp)(PyObject *, void *, int), + PyObject *(*exp)(PyObject *, void *, size_t), void (*drop)(void *)); /*----- Bytestrings -------------------------------------------------------*/ diff --git a/catacomb.c b/catacomb.c index d994347..1f38213 100644 --- a/catacomb.c +++ b/catacomb.c @@ -35,10 +35,11 @@ PyObject *mexp_common(PyObject *me, PyObject *arg, PyObject *(*id)(PyObject *), int (*fill)(void *, PyObject *, PyObject *, PyObject *), - PyObject *(*exp)(PyObject *, void *, int), + PyObject *(*exp)(PyObject *, void *, size_t), void (*drop)(void *)) { - int i = 0, j, n, flat; + size_t i = 0, j, n; + int flat; PyObject *qq, *x, *y, *z = 0; char *v = 0, *vv; diff --git a/ec.c b/ec.c index 9af2b0c..2ab20a6 100644 --- a/ec.c +++ b/ec.c @@ -913,7 +913,7 @@ static int ecmmul_fill(void *pp, PyObject *me, PyObject *x, PyObject *m) return (0); } -static PyObject *ecmmul_exp(PyObject *me, void *pp, int n) +static PyObject *ecmmul_exp(PyObject *me, void *pp, size_t n) { ec p = EC_INIT; ec_immul(ECCURVE_C(me), &p, pp, n); diff --git a/group.c b/group.c index 1e93ccc..77c3e9f 100644 --- a/group.c +++ b/group.c @@ -773,7 +773,7 @@ static PyObject *gemeth_toraw(PyObject *me) return (rc); } -static PyObject *gmexp_exp(PyObject *me, void *pp, int n) +static PyObject *gmexp_exp(PyObject *me, void *pp, size_t n) { ge *z = G_CREATE(GROUP_G(me)); G_MEXP(GROUP_G(me), z, pp, n); diff --git a/mp.c b/mp.c index 456c905..265a5c8 100644 --- a/mp.c +++ b/mp.c @@ -1332,7 +1332,7 @@ fail: return (-1); } -static PyObject *mm_mexpr(PyObject *me, void *v, int n) +static PyObject *mm_mexpr(PyObject *me, void *v, size_t n) { return mp_pywrap(mpmont_mexpr(MPMONT_PY(me), MP_NEW, v, n)); } static void mp_mexp_drop(void *p) @@ -1372,7 +1372,7 @@ fail: return (-1); } -static PyObject *mm_mexp(PyObject *me, void *v, int n) +static PyObject *mm_mexp(PyObject *me, void *v, size_t n) { return mp_pywrap(mpmont_mexp(MPMONT_PY(me), MP_NEW, v, n)); } static PyObject *mmmeth_mexp(PyObject *me, PyObject *arg) @@ -1527,7 +1527,7 @@ end: return (rc); } -static PyObject *mb_mexp(PyObject *me, void *v, int n) +static PyObject *mb_mexp(PyObject *me, void *v, size_t n) { return mp_pywrap(mpbarrett_mexp(MPBARRETT_PY(me), MP_NEW, v, n)); } static PyObject *mbmeth_mexp(PyObject *me, PyObject *arg) -- 2.11.0