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

Ensure NULL-termination of string when unescaping single-quotes #514

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

acritox
Copy link
Contributor

@acritox acritox commented Oct 26, 2023

The for-loop is copying a string character by character and replacing '' with '
by skipping a character if the current and next one are both '. When this
replacement doesn't occur then the target string will be filled completly
without a `\0' terminator at the end of the string.

here's a (redacted) screenshot showing the effect of this bug:
image
which then results in an apply error like:

ERROR: bind message supplies 6 parameters, but prepared statement "…" requires 7

or it could result in corrupted data if if the uninitialized memory happens to be valid UTF-8 bytes/characters for JSON strings

The for-loop is copying a string character by character and replacing `''` with `'`
by skipping a character if the current and next one are both `'`. When this
replacement doesn't occur then the target string will be filled completly
without a `\0' terminator at the end of the string.
@acritox acritox force-pushed the fix-null-termination branch from a5395d4 to f323be3 Compare October 26, 2023 23:49
@dimitri dimitri merged commit f92b03a into dimitri:main Oct 30, 2023
15 checks passed
@dimitri
Copy link
Owner

dimitri commented Oct 30, 2023

Thanks @acritox for your contribution, much appreciated!

@acritox acritox deleted the fix-null-termination branch October 30, 2023 14:01
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.

2 participants