-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
bpo-43984: Update winreg.SetValueEx to make sure the value set is not -1 #25775
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
Conversation
Skip news |
Can anyone please add a skip news label to this PR? |
Isn't this a change of behaviour? If so, I'd say it calls for a NEWS item. |
News entry added |
Perhaps you could use the bug report to write a test case? (Lib/test/test_winreg.py) |
Misc/NEWS.d/next/Windows/2021-05-02-15-29-33.bpo-43984.U92jiv.rst
Outdated
Show resolved
Hide resolved
Misc/NEWS.d/next/Windows/2021-05-02-15-29-33.bpo-43984.U92jiv.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Lib/test/test_winreg.py
Outdated
def test_setvalueex_negative_one_check(self): | ||
# Test for Issue #43984, check -1 was not set by SetValueEx. | ||
# Py2Reg, which gets called by SetValueEx, wasn't checking return | ||
# value by PyLong_AsUnsignedLong, thus setting -1 as value in the registry. | ||
# The implementation now checks PyLong_AsUnsignedLong return value to assure | ||
# the value set was not -1. | ||
try: | ||
with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: | ||
with self.assertRaises(OverflowError): | ||
SetValueEx(ck, "test_name", None, REG_DWORD, -1) | ||
with self.assertRaises(FileNotFoundError): | ||
with QueryValueEx(ck, "test_name") as subkey: | ||
pass | ||
finally: | ||
DeleteKey(HKEY_CURRENT_USER, test_key_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's something wrong with this test I added. My antivirus is identifying this piece of code as virus. Any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If any maintainers figure out the problem please add the required commit. Who cannot add commits please suggest the patch, I'll commit it.
This PR is stale because it has been open for 30 days with no activity. |
A Friendly Ping. |
Sorry for the lack of review. Unfortunately, it looks like someone added a new required check, so I'll close/reopen to re-run it, but the change looks okay to me. If someone else gets back to this before I do, they can merge. |
✅ Deploy Preview for python-cpython-preview canceled.
|
The test failure on Azure Pipelines is patchcheck reporting extra whitespace in the new test. I can't see it in the diff, but I find it's usually trailing whitespace in a comment. We shouldn't merge with that failure, or it'll show up randomly in the future. |
Thanks @shreyanavigyan for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
GH-100134 is a backport of this pull request to the 3.11 branch. |
GH-100135 is a backport of this pull request to the 3.10 branch. |
Thanks! FWIW, I suspect the antimalware detection was probably because it's an unsigned binary messing with the registry. Once we do our signed release, I'm sure it'll be fine. |
…n error (pythonGH-25775) (cherry picked from commit a29a7b9) Co-authored-by: Shreyan Avigyan <shreyan.avigyan@gmail.com>
…n error (pythonGH-25775) (cherry picked from commit a29a7b9) Co-authored-by: Shreyan Avigyan <shreyan.avigyan@gmail.com>
bpo-43984: Update winreg.SetValueEx to make sure the value set is not -1
REG_QWORD
case inPy2Reg
REG_DWORD
case inPy2Reg
https://bugs.python.org/issue43984