Re: python on 64bit platforms
Mike Ivanov <[email protected]>
| Newsgroups | gmane.comp.encryption.cryptlib |
|---|---|
| Organization | ActiveState |
| Message-ID | <[email protected]> |
On 10-05-01 2:57 AM, Peter Gutmann wrote: > Mike Ivanov<[email protected]> writes: > > >> I had to patch bindings/python.c in order to get it working on my 64-bit >> MacBook. In fact, there was a memory access bug caused rewriting arguments in >> python_cryptSetAttributeString (and presumably other places) on all 64-bit >> systems. >> >> The question is whether should I send the patch? Is it OK to post it right >> here? >> > Sure, however python.c is auto-generated by tools/cryptlibConverter.py so > unfortunately a change to that will only last until the next release. Any > chance you could make the change in cryptlibConverter.py instead? > > Peter. > Here's the patch. I've put together a walk-through here: http://www.mikeivanov.com/2010/05/how-to-make-cryptlibpy-work-on-64-bit.html Mike _______________________________________________ Cryptlib mailing list [email protected] via Mail: [email protected] Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/ http://news.gmane.org/gmane.comp.encryption.cryptlib Posts from non-subscribed addresses are blocked to prevent spam, please subscribe in order to post messages.
cryptlibConverter.py.patch
(text/plain, 1.3 KB)
--- tools/cryptlibConverter.py 2010-05-04 18:05:55.000000000 -0700
+++ tools/cryptlibConverter.py 2010-05-04 18:05:39.000000000 -0700
@@ -327,9 +327,12 @@
return 1;
}
+ Py_ssize_t size = 0;
+
/*See if it's an array object*/
- if (PyObject_AsWriteBuffer(objPtr, bytesPtrPtr, lengthPtr) == -1)
+ if (PyObject_AsWriteBuffer(objPtr, (void **)bytesPtrPtr, &size) == -1)
return 0;
+ *lengthPtr = size;
return 1;
}
@@ -342,16 +345,19 @@
return 1;
}
+ Py_ssize_t size = 0;
+
/*See if it's an array object*/
- if (PyObject_AsWriteBuffer(objPtr, bytesPtrPtr, lengthPtr) == -1)
+ if (PyObject_AsWriteBuffer(objPtr, (void **)bytesPtrPtr, &size) == -1)
{
PyErr_Clear();
/*See if it's a string object*/
/*This returns the length excluding the NULL if it's a string,
which is what we want*/
- if (PyObject_AsCharBuffer(objPtr, bytesPtrPtr, lengthPtr) == -1)
+ if (PyObject_AsCharBuffer(objPtr, (const char **)bytesPtrPtr, &size) == -1)
return 0;
}
+ *lengthPtr = size;
return 1;
}
@@ -379,7 +385,7 @@
static int getPointerReadString(PyObject* objPtr, char** charPtrPtr)
{
- int length = 0;
+ Py_ssize_t length = 0;
char* newPtr = NULL;
if (objPtr == Py_None)