Skip to content

Commit

Permalink
00398: fix stack overwrite on 32-bit in perf map test harness (python…
Browse files Browse the repository at this point in the history
…GH-104811) (python#104823)

pythongh-103295: fix stack overwrite on 32-bit in perf map test harness (pythonGH-104811)
(cherry picked from commit e0b3078)

Co-authored-by: Carl Meyer <carl@oddbird.net>
  • Loading branch information
hrnciar and carljm committed May 24, 2023
1 parent 55b2516 commit 7353ed8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,19 +762,24 @@ clear_extension(PyObject *self, PyObject *args)
static PyObject *
write_perf_map_entry(PyObject *self, PyObject *args)
{
PyObject *code_addr_v;
const void *code_addr;
unsigned int code_size;
const char *entry_name;

if (!PyArg_ParseTuple(args, "KIs", &code_addr, &code_size, &entry_name))
if (!PyArg_ParseTuple(args, "OIs", &code_addr_v, &code_size, &entry_name))
return NULL;
code_addr = PyLong_AsVoidPtr(code_addr_v);
if (code_addr == NULL) {
return NULL;
}

int ret = PyUnstable_WritePerfMapEntry(code_addr, code_size, entry_name);
if (ret == -1) {
PyErr_SetString(PyExc_OSError, "Failed to write performance map entry");
if (ret < 0) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
return Py_BuildValue("i", ret);
return PyLong_FromLong(ret);
}

static PyObject *
Expand Down

0 comments on commit 7353ed8

Please sign in to comment.