-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Prevent null characters from getting into SQLite #2289
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ghost
added
the
Issue-Bug
It either shouldn't be doing this or needs an investigation.
label
Jun 29, 2022
yao-msft
reviewed
Jul 1, 2022
CompositeTestSetup setup{ CompositeSearchBehavior::AvailablePackages }; | ||
setup.Available->Everything.Matches.emplace_back(MakeInstalled(), Criteria()); | ||
|
||
// We are mostly testing to see if a null installed version causes an AV or not |
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.
yao-msft
reviewed
Jul 1, 2022
@@ -102,6 +102,7 @@ | |||
#define APPINSTALLER_CLI_ERROR_PORTABLE_UNINSTALL_FAILED ((HRESULT)0x8A150057) | |||
#define APPINSTALLER_CLI_ERROR_ARP_VERSION_VALIDATION_FAILED ((HRESULT)0x8A150058) | |||
#define APPINSTALLER_CLI_ERROR_UNSUPPORTED_ARGUMENT ((HRESULT)0x8A150059) | |||
#define APPINSTALLER_CLI_ERROR_BIND_WITH_EMBEDDED_NULL ((HRESULT)0x8A150060) |
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.
yao-msft
approved these changes
Jul 1, 2022
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2273
Issue
The root of #2273 and some previous crashes in the same area is that SQLite does not handle null characters in strings in an intuitive way. Specifically, you can insert a string with null characters, but selecting that value out as a string results in a value that is terminates at the first null character. However, equality comparisons against that string value in the database require the full value, including nulls, to be true.
All of this lead to the following:
DisplayVersion
of an ARP entry were read ina. Here is where the bug strikes, the selected version string will not equal the value in the database due to the null character
The previous mitigation prevented the crash by simply dropping that package from
list
, but this change allows those entries to show again.Change
In order to prevent null characters from entering SQLite at all, the string binding functions are updated to throw if an embedded null is present. Additionally, the consistency check is updated to detect strings with embedded null characters.
In order to prevent attempting to send null characters into the database at all, the
NormalizedString
type used throughout the manifest is updated to also replace any null characters with spaces. This will allow those packages to be listed now.Validation
Added unit tests covering the changed behaviors.
Manually inserted a null character into a
DisplayVersion
registry entry on my machine:Microsoft Reviewers: Open in CodeFlow