Skip to content

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

Merged
merged 18 commits into from
Dec 9, 2022

Conversation

shreyanavigyan
Copy link
Contributor

@shreyanavigyan shreyanavigyan commented May 1, 2021

bpo-43984: Update winreg.SetValueEx to make sure the value set is not -1

  • Fix REG_QWORD case in Py2Reg
  • Fix REG_DWORD case in Py2Reg
  • Add test
  • Make sure the test does not appear as virus to the antivirus software!

https://bugs.python.org/issue43984

@shreyanavigyan
Copy link
Contributor Author

Skip news

@shreyanavigyan shreyanavigyan changed the title bpo-43984: Update winreg.SetValueEx to make sure the returned value is not -1 bpo-43984: Update winreg.SetValueEx to make sure the value set is not -1 May 1, 2021
@shreyanavigyan
Copy link
Contributor Author

Can anyone please add a skip news label to this PR?

@erlend-aasland
Copy link
Contributor

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.

@shreyanavigyan
Copy link
Contributor Author

News entry added

@shreyanavigyan shreyanavigyan requested review from pfmoore and removed request for a team May 2, 2021 10:55
@erlend-aasland
Copy link
Contributor

Perhaps you could use the bug report to write a test case? (Lib/test/test_winreg.py)

@python python deleted a comment May 4, 2021
shreyanavigyan and others added 4 commits May 9, 2021 00:35
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Comment on lines 343 to 357
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)
Copy link
Contributor Author

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?

Copy link
Contributor Author

@shreyanavigyan shreyanavigyan May 8, 2021

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.

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Jun 10, 2021
@shreyanavigyan
Copy link
Contributor Author

A Friendly Ping.

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Jun 11, 2021
@zooba
Copy link
Member

zooba commented Jul 6, 2021

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.

@zooba zooba closed this Jul 6, 2021
@zooba zooba reopened this Jul 6, 2021
@netlify
Copy link

netlify bot commented Dec 8, 2022

Deploy Preview for python-cpython-preview canceled.

Name Link
🔨 Latest commit 06da229
🔍 Latest deploy log https://app.netlify.com/sites/python-cpython-preview/deploys/6393215daba0e50008844eb4

@zooba
Copy link
Member

zooba commented Dec 9, 2022

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.

@zooba zooba added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels Dec 9, 2022
@zooba zooba merged commit a29a7b9 into python:main Dec 9, 2022
@miss-islington
Copy link
Contributor

Thanks @shreyanavigyan for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-100134 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Dec 9, 2022
@bedevere-bot
Copy link

GH-100135 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Dec 9, 2022
@zooba
Copy link
Member

zooba commented Dec 9, 2022

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.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 9, 2022
…n error (pythonGH-25775)

(cherry picked from commit a29a7b9)

Co-authored-by: Shreyan Avigyan <shreyan.avigyan@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 9, 2022
…n error (pythonGH-25775)

(cherry picked from commit a29a7b9)

Co-authored-by: Shreyan Avigyan <shreyan.avigyan@gmail.com>
miss-islington added a commit that referenced this pull request Dec 9, 2022
…n error (GH-25775)

(cherry picked from commit a29a7b9)

Co-authored-by: Shreyan Avigyan <shreyan.avigyan@gmail.com>
miss-islington added a commit that referenced this pull request Dec 9, 2022
…n error (GH-25775)

(cherry picked from commit a29a7b9)

Co-authored-by: Shreyan Avigyan <shreyan.avigyan@gmail.com>
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.