From 7f8c2476ae775cfe27be5a216cebb6ad35432185 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Fri, 18 Oct 2019 22:15:46 +0100 Subject: [PATCH] ec.c (eccurve_pyrichcompare): Check that second operand has correct type. A segfault waiting to happen, which has been lurking since the beginning. --- ec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ec.c b/ec.c index c8cdebe..0df218b 100644 --- a/ec.c +++ b/ec.c @@ -788,7 +788,11 @@ static PyTypeObject ecptcurve_pytype_skel = { static PyObject *eccurve_pyrichcompare(PyObject *x, PyObject *y, int op) { - int b = ec_samep(ECCURVE_C(x), ECCURVE_C(y)); + int b; + + assert(ECCURVE_PYCHECK(x)); + if (!ECCURVE_PYCHECK(y)) RETURN_NOTIMPL; + b = ec_samep(ECCURVE_C(x), ECCURVE_C(y)); switch (op) { case Py_EQ: break; case Py_NE: b = !b; break; -- 2.11.0