[Python-checkins] r42775 - python/trunk/Modules/_hashopenssl.c

thomas.wouters python-checkins at python.org
Thu Mar 2 06:05:19 CET 2006


Author: thomas.wouters
Date: Thu Mar 2 06:05:17 2006
New Revision: 42775
Modified:
 python/trunk/Modules/_hashopenssl.c
Log:
Properly fix Py_SAFE_DOWNCAST-triggerd bugs.
Modified: python/trunk/Modules/_hashopenssl.c
==============================================================================
--- python/trunk/Modules/_hashopenssl.c	(original)
+++ python/trunk/Modules/_hashopenssl.c	Thu Mar 2 06:05:17 2006
@@ -173,7 +173,8 @@
 if (!PyArg_ParseTuple(args, "s#:update", &cp, &len))
 return NULL;
 
- EVP_DigestUpdate(&self->ctx, cp, (unsigned int)len);
+ EVP_DigestUpdate(&self->ctx, cp, Py_SAFE_DOWNCAST(len, Py_ssize_t,
+ unsigned int));
 
 Py_INCREF(Py_None);
 return Py_None;
@@ -240,7 +241,7 @@
 PyObject *name_obj = NULL;
 char *nameStr;
 unsigned char *cp = NULL;
- Py_ssize_t len;
+ Py_ssize_t len = 0;
 const EVP_MD *digest;
 
 if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|s#:HASH", kwlist,
@@ -264,7 +265,8 @@
 Py_INCREF(self->name);
 
 if (cp && len)
- EVP_DigestUpdate(&self->ctx, cp, (unsigned int)len);
+ EVP_DigestUpdate(&self->ctx, cp, Py_SAFE_DOWNCAST(len, Py_ssize_t,
+ unsigned int));
 
 return 0;
 }
@@ -377,7 +379,7 @@
 char *name;
 const EVP_MD *digest;
 unsigned char *cp = NULL;
- Py_ssize_t len;
+ Py_ssize_t len = 0;
 
 if (!PyArg_ParseTupleAndKeywords(args, kwdict, "O|s#:new", kwlist,
 &name_obj, &cp, &len)) {
@@ -391,7 +393,8 @@
 
 digest = EVP_get_digestbyname(name);
 
- return EVPnew(name_obj, digest, NULL, cp, (unsigned int)len);
+ return EVPnew(name_obj, digest, NULL, cp, Py_SAFE_DOWNCAST(len, Py_ssize_t,
+ unsigned int));
 }
 
 /*
@@ -406,7 +409,7 @@
 EVP_new_ ## NAME (PyObject *self, PyObject *args) \
 { \
 unsigned char *cp = NULL; \
- Py_ssize_t len; \
+ Py_ssize_t len = 0; \
 \
 if (!PyArg_ParseTuple(args, "|s#:" #NAME , &cp, &len)) { \
 return NULL; \
@@ -416,7 +419,7 @@
 CONST_ ## NAME ## _name_obj, \
 NULL, \
 CONST_new_ ## NAME ## _ctx_p, \
- cp, (unsigned int)len); \
+ cp, Py_SAFE_DOWNCAST(len, Py_ssize_t, unsigned int)); \
 }
 
 /* a PyMethodDef structure for the constructor */


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /