Skip to content

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

Merged
zooba merged 18 commits into
python:mainfrom
shreyanavigyan:bpo-43984
Dec 9, 2022
Merged

bpo-43984: Update winreg.SetValueEx to make sure the value set is not -1#25775
zooba merged 18 commits into
python:mainfrom
shreyanavigyan:bpo-43984

Conversation

@shreyanavigyan

@shreyanavigyanshreyanavigyan commented May 1, 2021

Copy link
Copy Markdown
Contributor

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
Copy Markdown
ContributorAuthor

Skip news

@shreyanavigyanshreyanavigyan changed the title bpo-43984: Update winreg.SetValueEx to make sure the returned value is not -1bpo-43984: Update winreg.SetValueEx to make sure the value set is not -1May 1, 2021
Comment threadPC/winreg.c
Comment threadPC/winreg.c Outdated
@shreyanavigyan

Copy link
Copy Markdown
ContributorAuthor

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

@erlend-aasland

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

News entry added

@shreyanavigyan
shreyanavigyan requested review from pfmoore and removed request for a teamMay 2, 2021 10:55
@erlend-aasland

Copy link
Copy Markdown
Contributor

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

@pythonpython deleted a comment May 4, 2021
Comment threadMisc/NEWS.d/next/Windows/2021-05-02-15-29-33.bpo-43984.U92jiv.rst Outdated
Comment threadPC/winreg.c Outdated
Comment threadPC/winreg.c Outdated
Comment threadMisc/NEWS.d/next/Windows/2021-05-02-15-29-33.bpo-43984.U92jiv.rst Outdated
shreyanavigyanand 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
Copy Markdown
ContributorAuthor

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?

@shreyanavigyanshreyanavigyanMay 8, 2021

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown

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

@github-actionsgithub-actionsBot added the stale Stale PR or inactive for long period of time. label Jun 10, 2021
@shreyanavigyan

Copy link
Copy Markdown
ContributorAuthor

A Friendly Ping.

@github-actionsgithub-actionsBot removed the stale Stale PR or inactive for long period of time. label Jun 11, 2021
@zooba

zooba commented Jul 6, 2021

Copy link
Copy Markdown
Member

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.

@zoobazooba closed this Jul 6, 2021
@zoobazooba reopened this Jul 6, 2021
@netlify

netlifyBot commented Dec 8, 2022

Copy link
Copy Markdown

Deploy Preview for python-cpython-preview canceled.

NameLink
🔨 Latest commit06da229
🔍 Latest deploy loghttps://app.netlify.com/sites/python-cpython-preview/deploys/6393215daba0e50008844eb4

@zooba

zooba commented Dec 9, 2022

Copy link
Copy Markdown
Member

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.

Comment threadLib/test/test_winreg.py Outdated
Comment threadLib/test/test_winreg.py Outdated
Comment threadLib/test/test_winreg.py
Comment threadLib/test/test_winreg.py
@zoobazooba 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:mainDec 9, 2022
@miss-islington

Copy link
Copy Markdown
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
Copy Markdown

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

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

Copy link
Copy Markdown

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

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

zooba commented Dec 9, 2022

Copy link
Copy Markdown
Member

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 freeto 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.

12 participants

@shreyanavigyan@erlend-aasland@eryksun@zooba@miss-islington@bedevere-bot@tjguk@pfmoore@AlexWaygood@the-knights-who-say-ni@ezio-melotti@iritkatriel