8000 gh-132915: Try to detect a buffer overflow in fcntl() and ioctl() by serhiy-storchaka · Pull Request #132919 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-132915: Try to detect a buffer overflow in fcntl() and ioctl() #132919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 28, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove debugging remnants.
  • Loading branch information
serhiy-storchaka authored Apr 28, 2025
commit 55de9626c3177338e75ac58e2caa7017f94b1de0
6 changes: 3 additions & 3 deletions Modules/fcntlmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fcntl_fcntl_impl(PyObject *module, int fd, int code, PyObject *arg)
return !async_err ? PyErr_SetFromErrno(PyExc_OSError) : NULL;
}
if (memcmp(buf + len, guard, GUARDSZ) != 0) {
PyErr_SetString(PyExc_SystemError, "buffer overflow1");
PyErr_SetString(PyExc_SystemError, "buffer overflow");
return NULL;
}
return PyBytes_FromStringAndSize(buf, len);
Expand Down Expand Up @@ -236,7 +236,7 @@ fcntl_ioctl_impl(PyObject *module, int fd, unsigned long code, PyObject *arg,
}
PyBuffer_Release(&view);
if (ptr == buf && memcmp(buf + len, guard, GUARDSZ) != 0) {
PyErr_SetString(PyExc_SystemError, "buffer overflow2");
PyErr_SetString(PyExc_SystemError, "buffer overflow");
return NULL;
}
return PyLong_FromLong(ret);
Expand Down Expand Up @@ -270,7 +270,7 @@ fcntl_ioctl_impl(PyObject *module, int fd, unsigned long code, PyObject *arg,
return !async_err ? PyErr_SetFromErrno(PyExc_OSError) : NULL;
}
if (memcmp(buf + len, guard, GUARDSZ) != 0) {
PyErr_SetString(PyExc_SystemError, "buffer overflow3");
PyErr_SetString(PyExc_SystemError, "buffer overflow");
return NULL;
}
return PyBytes_FromStringAndSize(buf, len);
Expand Down
Loading 3A7A
0