Skip to content

Fix GH-18148: pg_copy_from() wrong \n offset check. #18149

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

Closed
wants to merge 1 commit into from

Conversation

devnexen
Copy link
Member

No description provided.

@devnexen devnexen linked an issue Mar 26, 2025 that may be closed by this pull request
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Looks reasonable

@@ -3451,11 +3451,12 @@ PHP_FUNCTION(pg_copy_from)
if (UNEXPECTED(!tmp)) {
return;
}
zend_string *zquery = zend_string_alloc(ZSTR_LEN(tmp) + 1, false);
zend_string *zquery = zend_string_alloc(ZSTR_LEN(tmp) + 2, false);
Copy link
Member

Choose a reason for hiding this comment

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

Can we have a comment for why this is +2?

Copy link

Choose a reason for hiding this comment

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

If the input string does not end with a linefeed, space is required for the input string plus a linefeed plus the final nul byte.

Copy link
Member Author

@devnexen devnexen Mar 26, 2025

Choose a reason for hiding this comment

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

She probably got it :) it was more a request than a question I believe, so we do not forget months later.

@rperske
Copy link

rperske commented Mar 26, 2025

Thank you so much for your ultra-quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pg_copy_from no longer accepts linefeed
3 participants