Skip to content

Commit

Permalink
[3.12] gh-103295: fix stack overwrite on 32-bit in perf map test harn…
Browse files Browse the repository at this point in the history
…ess (GH-104811) (#104823)

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

Co-authored-by: Carl Meyer <carl@oddbird.net>
  • Loading branch information
miss-islington and carljm authored May 23, 2023
1 parent 5c8418c commit 22c45c4
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 22c45c4

Please sign in to comment.