CVS: crypto/src _fastmath.c,1.3,1.4

"A.M. Kuchling" <[email protected]> Thu, 03 Apr 2003 10:53:34 -0800
Newsgroups gmane.comp.python.cryptography.cvs
Message-ID <[email protected]>
Update of /cvsroot/pycrypto/crypto/src
In directory sc8-pr-cvs1:/tmp/cvs-serv21045

Modified Files:
	_fastmath.c 
Log Message:
Eek!  Check error return from PyArg_ParseTuple

Index: _fastmath.c
===================================================================
RCS file: /cvsroot/pycrypto/crypto/src/_fastmath.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- _fastmath.c	3 Apr 2003 18:47:22 -0000	1.3
+++ _fastmath.c	3 Apr 2003 18:53:31 -0000	1.4
@@ -252,15 +252,17 @@
 {
 	PyLongObject *y = NULL, *g = NULL, *p = NULL, *q = NULL, *x = NULL;
 	dsaKey *key;
+	if (!PyArg_ParseTuple(args, "O!O!O!O!|O!", &PyLong_Type, &y,
+			      &PyLong_Type, &g, &PyLong_Type, &p, 
+			      &PyLong_Type, &q, &PyLong_Type, &x))
+		return NULL;
+
 	key = PyObject_New (dsaKey, &dsaKeyType);
 	mpz_init (key->y);
 	mpz_init (key->g);
 	mpz_init (key->p);
 	mpz_init (key->q);
 	mpz_init (key->x);
-	PyArg_ParseTuple(args, "O!O!O!O!|O!", &PyLong_Type, &y,
-			 &PyLong_Type, &g,
-			 &PyLong_Type, &p, &PyLong_Type, &q, &PyLong_Type, &x);
 	longObjToMPZ (key->y, y);
 	longObjToMPZ (key->g, g);
 	longObjToMPZ (key->p, p);
@@ -321,8 +323,8 @@
 	PyObject *lm, *lk, *lr, *ls;
 	mpz_t m, k, r, s;
 	int result;
-	if (!(PyArg_ParseTuple (args, "O!O!", &PyLong_Type, &lm,
-				&PyLong_Type, &lk)))
+	if (!PyArg_ParseTuple (args, "O!O!", &PyLong_Type, &lm,
+			       &PyLong_Type, &lk))
 	{
 		return NULL;
 	}
@@ -353,8 +355,8 @@
 	PyObject *lm, *lr, *ls;
 	mpz_t m, r, s;
 	int result;
-	if (!(PyArg_ParseTuple (args, "O!O!O!", &PyLong_Type, &lm,
-				&PyLong_Type, &lr, &PyLong_Type, &ls)))
+	if (!PyArg_ParseTuple (args, "O!O!O!", &PyLong_Type, &lm,
+			       &PyLong_Type, &lr, &PyLong_Type, &ls))
 	{
 		return NULL;
 	}
@@ -395,15 +397,18 @@
 {
 	PyLongObject *n = NULL, *e = NULL, *d = NULL, *p = NULL, *q = NULL;
 	rsaKey *key;
+
+	if (!PyArg_ParseTuple(args, "O!O!|O!O!O!", &PyLong_Type, &n,
+			      &PyLong_Type, &e, &PyLong_Type, &d, 
+			      &PyLong_Type, &p, &PyLong_Type, &q))
+		return NULL;
+
 	key = PyObject_New (rsaKey, &rsaKeyType);
 	mpz_init (key->n);
 	mpz_init (key->e);
 	mpz_init (key->d);
 	mpz_init (key->p);
 	mpz_init (key->q);
-	PyArg_ParseTuple (args, "O!O!|O!O!O!", &PyLong_Type, &n,
-			  &PyLong_Type, &e,
-			  &PyLong_Type, &d, &PyLong_Type, &p, &PyLong_Type, &q);
 	longObjToMPZ (key->n, n);
 	longObjToMPZ (key->e, e);
 	if (!d)



-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/