ec.c (ec2osp, os2ecp): Collect flags correctly.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 12 Oct 2019 12:44:54 +0000 (13:44 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 17 Nov 2019 02:50:40 +0000 (02:50 +0000)
Previously `ec2osp' collected an `int', which probably wasn't completely
terrible, and `os2ecp' collected a float, which probably was.

ec.c

diff --git a/ec.c b/ec.c
index 7fd369d..4ee4d05 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -298,11 +298,12 @@ static PyObject *epmeth_ec2osp(PyObject *me, PyObject *arg, PyObject *kw)
   char *p;
   ec_curve *c = ECPT_C(me);
   ec pp = EC_INIT;
-  int f = EC_EXPLY;
+  unsigned f = EC_EXPLY;
   int len;
   char *kwlist[] = { "flags", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|i:ec2osp", kwlist, &f))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:ec2osp", kwlist,
+                                  convuint, &f))
     return (0);
   len = c->f->noctets * 2 + 1;
   rc = bytestring_pywrap(0, len);
@@ -866,12 +867,12 @@ static PyObject *meth__ECPtCurve_os2ecp(PyObject *me,
   buf b;
   PyObject *rc = 0;
   ec_curve *cc;
-  int f = EC_XONLY | EC_LSB | EC_SORT | EC_EXPLY;
+  unsigned f = EC_XONLY | EC_LSB | EC_SORT | EC_EXPLY;
   ec pp = EC_INIT;
   char *kwlist[] = { "class", "buf", "flags", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "Os#|f:os2ecp", kwlist,
-                                  &me, &p, &len, &f))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "Os#|O&:os2ecp", kwlist,
+                                  &me, &p, &len, convuint, &f))
     return (0);
   buf_init(&b, p, len);
   cc = ECCURVE_C(me);