Skip to content

Conversation

@ashm-dev
Copy link
Contributor

@ashm-dev ashm-dev commented Nov 13, 2025

Fixes buffer overflow (CVE-2006-1542) in _Py_wrealpath() when handling paths longer than MAXPATHLEN (4096 bytes).

Changed realpath(path, buffer) to realpath(path, NULL) for dynamic allocation.

Closes #42400

Allow platforms where realpath returns different canonical paths (e.g.
Android). Verify resolution with os.samefile and fall back to a length
check if samefile is unavailable.
@ashm-dev
Copy link
Contributor Author

I don't think the errors in the UBSAN test are related to this fix, as they occur for a completely different reason and generally in import tests.

@ashm-dev
Copy link
Contributor Author

@vstinner Could you please review this PR?

@ashm-dev ashm-dev requested a review from vstinner November 14, 2025 11:08
@vstinner
Copy link
Member

I updated the PR to retrieve the fix for the UBSan CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid using unsafe realpath

2 participants