-
Notifications
You must be signed in to change notification settings - Fork 23
Fix boolean buffer overflow #191
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
Open
richardm90
wants to merge
4
commits into
IBM:master
Choose a base branch
from
richardm90:fix/boolean-buffer-overflow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cabd0b5
test: add BOOLEAN, CHAR, and VARCHAR data type tests
richardm90 17bf83c
test: add CHAR, VARCHAR, BOOLEAN, and multi-byte UTF-8 data type tests
richardm90 c4419c3
fix: prevent buffer overread when fetching string column data
richardm90 e1f91b1
fix: handle BOOLEAN/DATALINK type code differences across IBM i versions
richardm90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
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.
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.
TBH I think we should bind booleans as a boolean type not as a string anyway. As mentioned in the PR description, the value of SQL_DATALINK was changed in 7.5 so that SQL_BOOLEAN could use its value for consistency with Db2 LUW. I argued against this change, but it was determined that there would be minimal impact because basically nobody uses DATALINKs anyway so we may as well do the same.
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.
@kadler, apologies for the delay, I'd turned off notifications some time ago and had forgotten that fact when I raised this PR. I'll have a look at the changes you suggest.
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.
@kadler, I've just implemented the changes to correctly handle the boolean data type.
The SQL type code 16 has different meanings across IBM i releases:
Additionally, boolean parameter binding in master was broken - it used
SQL_C_BIT which IBM i CLI rejects with error HY003.
I've made three key changes in this PR:
Backward Compatibility
✅ On V7R4: DATALINK columns (type 16) correctly returned as strings
✅ On V7R5+: BOOLEAN columns (type 16) correctly returned as booleans
✅ On V7R5+: DATALINK columns (type -400) correctly returned as strings
When running the tests on V7R4 (or lower) there will be four failures, the new boolean tests; the new datalink test will succeed. When running the tests on V7R5 (or higher) all test are successful.
Note that the datalink data type is not well supported by the connector. I have added tests that check for a datalink column in the result but work would be required to handle parameter binding.
I've not added any comments to
README.mdabout changes to theBOOLEANdata type handling. Anybody already using the connector andBOOLEANwill now be dealing with a true boolean rather than a string representation. Happy to do that if you think it's appropriate.