Skip to content

gh-144206: Improve error messages for buffer overflow in fcntl.fcntl() and fcntl.ioctl()#144273

Merged
serhiy-storchaka merged 2 commits intopython:mainfrom
serhiy-storchaka:fcntl-buffer-overflow-errmsg
Jan 29, 2026
Merged

gh-144206: Improve error messages for buffer overflow in fcntl.fcntl() and fcntl.ioctl()#144273
serhiy-storchaka merged 2 commits intopython:mainfrom
serhiy-storchaka:fcntl-buffer-overflow-errmsg

Conversation

@serhiy-storchaka
Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka commented Jan 27, 2026

Comment thread Misc/NEWS.d/next/Library/2026-01-27-14-23-10.gh-issue-144206.l0un4U.rst Outdated
Co-authored-by: Victor Stinner <vstinner@python.org>
Comment thread Modules/fcntlmodule.c
PyErr_SetString(PyExc_SystemError, "buffer overflow");
PyErr_SetString(PyExc_SystemError,
"Possible stack corruption in fcntl() due to "
"buffer overflow. "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use a different message for the memcmp() case? It's not a "Memory corruption" here as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends whether the buffer was on the stack or in the heap memory (preallocated bytes object).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends whether the buffer was on the stack or in the heap memory (preallocated bytes object).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok, it makes sense. I didn't notice that one code path allocated memory on the stack.

Copy link
Copy Markdown
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@serhiy-storchaka serhiy-storchaka merged commit a7cec56 into python:main Jan 29, 2026
51 checks passed
@serhiy-storchaka serhiy-storchaka deleted the fcntl-buffer-overflow-errmsg branch January 29, 2026 13:04
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants