Update Python 3.10 patch to work on arches other than x86

f38
Paul Howarth 4 years ago
parent d58575d615
commit bf9fa2dc35

@ -1,3 +1,23 @@
--- src/AES.c
+++ src/AES.c
@@ -26,6 +26,7 @@
#include <assert.h>
#include <stdlib.h>
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
#define MODULE_NAME _AES
--- src/ARC2.c
+++ src/ARC2.c
@@ -42,6 +42,7 @@
*/
#include <string.h>
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
#define MODULE_NAME _ARC2
--- src/block_template.c --- src/block_template.c
+++ src/block_template.c +++ src/block_template.c
@@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
@ -45,38 +65,74 @@
new->mode = mode; new->mode = mode;
new->count=BLOCK_SIZE; /* stores how many bytes in new->oldCipher have been used */ new->count=BLOCK_SIZE; /* stores how many bytes in new->oldCipher have been used */
return new; return new;
@@ -265,10 +267,12 @@ ALG_Encrypt(ALGobject *self, PyObject *a @@ -264,7 +266,8 @@ ALG_Encrypt(ALGobject *self, PyObject *a
{
unsigned char *buffer, *str; unsigned char *buffer, *str;
unsigned char temp[BLOCK_SIZE]; unsigned char temp[BLOCK_SIZE];
int i, j, len; - int i, j, len;
+ Py_ssize_t param_len; + int i, j;
+ Py_ssize_t len;
PyObject *result; PyObject *result;
- if (!PyArg_Parse(args, "s#", &str, &len)) if (!PyArg_Parse(args, "s#", &str, &len))
+ if (!PyArg_Parse(args, "s#", &str, &param_len)) @@ -292,7 +295,7 @@ ALG_Encrypt(ALGobject *self, PyObject *a
return NULL; return NULL;
+ len = (int)param_len; }
if (len==0) /* Handle empty string */
- buffer=malloc(len);
+ buffer=malloc((size_t)len);
if (buffer==NULL)
{ {
return PyBytes_FromStringAndSize(NULL, 0); PyErr_SetString(PyExc_MemoryError,
@@ -497,14 +501,16 @@ ALG_Decrypt(ALGobject *self, PyObject *a @@ -496,7 +499,8 @@ ALG_Decrypt(ALGobject *self, PyObject *a
{
unsigned char *buffer, *str; unsigned char *buffer, *str;
unsigned char temp[BLOCK_SIZE]; unsigned char temp[BLOCK_SIZE];
int i, j, len; - int i, j, len;
+ Py_ssize_t param_len; + int i, j;
+ Py_ssize_t len;
PyObject *result; PyObject *result;
/* CTR mode decryption is identical to encryption */ /* CTR mode decryption is identical to encryption */
if (self->mode == MODE_CTR) @@ -525,7 +529,7 @@ ALG_Decrypt(ALGobject *self, PyObject *a
return ALG_Encrypt(self, args); self->segment_size/8);
- if (!PyArg_Parse(args, "s#", &str, &len))
+ if (!PyArg_Parse(args, "s#", &str, &param_len))
return NULL; return NULL;
+ len = (int)param_len; }
if (len==0) /* Handle empty string */ - buffer=malloc(len);
+ buffer=malloc((size_t)len);
if (buffer==NULL)
{ {
return PyBytes_FromStringAndSize(NULL, 0); PyErr_SetString(PyExc_MemoryError,
--- src/Blowfish.c
+++ src/Blowfish.c
@@ -36,6 +36,7 @@
#endif
#include <assert.h>
#include <string.h>
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "Blowfish-tables.h"
--- src/CAST.c
+++ src/CAST.c
@@ -42,6 +42,7 @@
*/
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
#define MODULE_NAME _CAST
--- src/DES.c
+++ src/DES.c
@@ -34,6 +34,7 @@
#undef DES /* this is needed because tomcrypt_custom.h defines DES to an empty string */
#include <assert.h>
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
typedef struct {
--- src/hash_template.c --- src/hash_template.c
+++ src/hash_template.c +++ src/hash_template.c
@@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
@ -105,6 +161,36 @@
if ((new = newALGobject()) == NULL) if ((new = newALGobject()) == NULL)
return NULL; return NULL;
--- src/MD2.c
+++ src/MD2.c
@@ -28,6 +28,7 @@
#include <string.h>
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycrypto_compat.h"
--- src/MD4.c
+++ src/MD4.c
@@ -28,6 +28,7 @@
#include <string.h>
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycrypto_compat.h"
--- src/RIPEMD160.c
+++ src/RIPEMD160.c
@@ -54,6 +54,7 @@
#include <assert.h>
#include <string.h>
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycrypto_compat.h"
--- src/stream_template.c --- src/stream_template.c
+++ src/stream_template.c +++ src/stream_template.c
@@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
@ -133,31 +219,71 @@
if (PyErr_Occurred()) if (PyErr_Occurred())
{ {
Py_DECREF(new); Py_DECREF(new);
@@ -141,10 +142,12 @@ ALG_Encrypt(ALGobject *self, PyObject *a @@ -140,7 +141,7 @@ static PyObject *
ALG_Encrypt(ALGobject *self, PyObject *args)
{ {
unsigned char *buffer, *str; unsigned char *buffer, *str;
int len; - int len;
+ Py_ssize_t param_len; + Py_ssize_t len;
PyObject *result; PyObject *result;
- if (!PyArg_Parse(args, "s#", &str, &len)) if (!PyArg_Parse(args, "s#", &str, &len))
+ if (!PyArg_Parse(args, "s#", &str, &param_len)) @@ -149,7 +150,7 @@ ALG_Encrypt(ALGobject *self, PyObject *a
return NULL;
+ len = (int)param_len;
if (len == 0) /* Handle empty string */
{ {
return PyBytes_FromStringAndSize(NULL, 0); return PyBytes_FromStringAndSize(NULL, 0);
@@ -173,10 +176,12 @@ ALG_Decrypt(ALGobject *self, PyObject *a }
- buffer = malloc(len);
+ buffer = malloc((size_t)len);
if (buffer == NULL)
{
PyErr_SetString(PyExc_MemoryError, "No memory available in "
@@ -157,8 +158,8 @@ ALG_Encrypt(ALGobject *self, PyObject *a
return NULL;
}
Py_BEGIN_ALLOW_THREADS;
- memcpy(buffer, str, len);
- stream_encrypt(&(self->st), buffer, len);
+ memcpy(buffer, str, (size_t)len);
+ stream_encrypt(&(self->st), buffer, (int)len);
Py_END_ALLOW_THREADS;
result = PyBytes_FromStringAndSize((char *)buffer, len);
free(buffer);
@@ -172,7 +173,7 @@ static PyObject *
ALG_Decrypt(ALGobject *self, PyObject *args)
{ {
unsigned char *buffer, *str; unsigned char *buffer, *str;
int len; - int len;
+ Py_ssize_t param_len; + Py_ssize_t len;
PyObject *result; PyObject *result;
- if (!PyArg_Parse(args, "s#", &str, &len)) if (!PyArg_Parse(args, "s#", &str, &len))
+ if (!PyArg_Parse(args, "s#", &str, &param_len)) @@ -181,7 +182,7 @@ ALG_Decrypt(ALGobject *self, PyObject *a
return NULL;
+ len = (int)param_len;
if (len == 0) /* Handle empty string */
{ {
return PyBytes_FromStringAndSize(NULL, 0); return PyBytes_FromStringAndSize(NULL, 0);
}
- buffer = malloc(len);
+ buffer = malloc((size_t)len);
if (buffer == NULL)
{
PyErr_SetString(PyExc_MemoryError, "No memory available in "
@@ -189,8 +190,8 @@ ALG_Decrypt(ALGobject *self, PyObject *a
return NULL;
}
Py_BEGIN_ALLOW_THREADS;
- memcpy(buffer, str, len);
- stream_decrypt(&(self->st), buffer, len);
+ memcpy(buffer, str, (size_t)len);
+ stream_decrypt(&(self->st), buffer, (int)len);
Py_END_ALLOW_THREADS;
result = PyBytes_FromStringAndSize((char *)buffer, len);
free(buffer);
--- src/XOR.c
+++ src/XOR.c
@@ -24,6 +24,7 @@
* =======================================================================
*/
+#define PY_SSIZE_T_CLEAN
#include "Python.h"
#define MODULE_NAME _XOR

Loading…
Cancel
Save