Skip to content
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

winansi: check result before using Name for pty #3875

Merged
merged 1 commit into from
May 30, 2022

Conversation

1480c1
Copy link

@1480c1 1480c1 commented May 28, 2022

NtQueryObject under Wine can return a success but fill out no name.
In those situations, Wine will set Buffer to NULL, and set result to
the sizeof(OBJECT_NAME_INFORMATION).

Running a command such as

echo "$(git.exe --version 2>/dev/null)"

will crash due to a NULL pointer dereference when the code attempts to
null terminate the buffer, although, weirdly, removing the subshell or
redirecting stdout to a file will not trigger the crash.

Alternatives include checking Buffer itself, however, I am not sure
what is the official behavior of the function due to a lack of
documentation.
Another alternative is to check the Length field, but similar to above,
I do not know what the official behavior is.

This code is based on the behavior of NtQueryObject under wine and
reactos.

Signed-off-by: Christopher Degawa ccom@randomderp.com

opened gitgitgadget#1245 for now

@1480c1
Copy link
Author

1480c1 commented May 28, 2022

hmm, seems the second commit will be unneeded after #3864

@1480c1
Copy link
Author

1480c1 commented May 28, 2022

rebased on top of #3864 so CI can pass for now, please ignore the commits other than the last one

@1480c1 1480c1 changed the title detect_msys_tty: check result before using Name winansi: check result before using Name for pty May 30, 2022
Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

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

Thank you for working the Wine angle of Git for Windows!

compat/winansi.c Outdated Show resolved Hide resolved
compat/winansi.c Outdated Show resolved Hide resolved
NtQueryObject under Wine can return a success but fill out no name.
In those situations, Wine will set Buffer to NULL, and set result to
the sizeof(OBJECT_NAME_INFORMATION).

Running a command such as

echo "$(git.exe --version 2>/dev/null)"

will crash due to a NULL pointer dereference when the code attempts to
null terminate the buffer, although, weirdly, removing the subshell or
redirecting stdout to a file will not trigger the crash.

Code has been added to also check Buffer and Length to ensure the check
is as robust as possible due to the current behavior being fragile at
best, and could potentially change in the future

This code is based on the behavior of NtQueryObject under wine and
reactos.

Signed-off-by: Christopher Degawa <ccom@randomderp.com>
@dscho
Copy link
Member

dscho commented May 30, 2022

Let's wait for the build to pass and then merge.

@dscho dscho added this to the Next release milestone May 30, 2022
@dscho dscho merged commit c5ca16f into git-for-windows:main May 30, 2022
@1480c1 1480c1 deleted the wine/detect_msys_tty branch May 30, 2022 18:18
git-for-windows-ci pushed a commit that referenced this pull request May 30, 2022
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request May 30, 2022
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request May 30, 2022
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request May 30, 2022
winansi: check result before using Name for pty
dscho added a commit to git-for-windows/build-extra that referenced this pull request May 30, 2022
A crash when running Git for Windows in Wine [was
fixed](git-for-windows/git#3875).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit that referenced this pull request May 31, 2022
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request May 31, 2022
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request May 31, 2022
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Jun 1, 2022
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Jun 1, 2022
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Jun 1, 2022
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Jun 2, 2022
winansi: check result before using Name for pty
dscho added a commit that referenced this pull request Sep 2, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 3, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 3, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 3, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 4, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 4, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 5, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 5, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 5, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 6, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 6, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 7, 2024
winansi: check result before using Name for pty
dscho added a commit that referenced this pull request Sep 9, 2024
winansi: check result before using Name for pty
dscho added a commit that referenced this pull request Sep 9, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 9, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 9, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 9, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 10, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 10, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 10, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 11, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 11, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 11, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 11, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 11, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 12, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 12, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 12, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 12, 2024
winansi: check result before using Name for pty
git-for-windows-ci pushed a commit that referenced this pull request Sep 13, 2024
winansi: check result before using Name for pty
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.

3 participants