Skip to content

bpo-41094: Fix decoding errors with audit when open files. #21095

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

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jun 23, 2020

@zooba
Copy link
Member

zooba commented Jun 23, 2020

I have no idea what the ossaudiodev failure relates to... that doesn't go through this code path does it?

@@ -1274,7 +1274,12 @@ _Py_open_impl(const char *pathname, int flags, int gil_held)
#endif

if (gil_held) {
if (PySys_Audit("open", "sOi", pathname, Py_None, flags) < 0) {
PyObject *pathname_obj = PyUnicode_DecodeFSDefault(pathname);
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to call should_audit() here to avoid decoding the string if audit is disabled?

Something like:

if (should_audit()) {
  pathname_obj = PyUnicode_DecodeFSDefault(pathname);
  PySys_Audit(pathname_obj)
  Py_DECREF(pathname_obj);
}

Same remark for _Py_fopen().

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not performance critical, and should_audit() is not available in Python/fileutils.c, so this needs additional work. I prefer to merge simple fix. You can add the call should_audit() in separate PR.

@serhiy-storchaka serhiy-storchaka merged commit 6c6810d into python:master Jun 24, 2020
@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the audit-locale-encoding branch June 24, 2020 05:46
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 24, 2020
…21095)

(cherry picked from commit 6c6810d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot
Copy link

GH-21107 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Jun 24, 2020
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 24, 2020
…21095)

(cherry picked from commit 6c6810d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot
Copy link

GH-21108 is a backport of this pull request to the 3.8 branch.

@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 24, 2020
…21095)

(cherry picked from commit 6c6810d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot
Copy link

GH-21120 is a backport of this pull request to the 3.9 branch.

@bedevere-bot
Copy link

GH-21121 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 24, 2020
…21095)

(cherry picked from commit 6c6810d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington added a commit that referenced this pull request Jun 24, 2020
(cherry picked from commit 6c6810d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington added a commit that referenced this pull request Jun 24, 2020
(cherry picked from commit 6c6810d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
fasih pushed a commit to fasih/cpython that referenced this pull request Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants