Skip to content

PHPC-1774 Fix truncation of PHP_VERSION constant in handshake metadata #1202

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

Merged
merged 2 commits into from
Feb 23, 2021

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Feb 17, 2021

PHPC-1774

@jmikola testing this is notoriously difficult, as I can't add the expected value of PHP_VERSION into the EXPECTF block. If you have any suggestion how to prevent regressions against this, please let me know.

@alcaeus alcaeus requested a review from jmikola February 17, 2021 11:10
@alcaeus alcaeus self-assigned this Feb 17, 2021
snprintf(php_version_string, 4 + php_version_string_len, "PHP %s", PHP_VERSION);
php_version_string_len = strlen(PHP_VERSION) + PHONGO_METADATA_PHP_VERSION_PREFIX_LEN + 1;
php_version_string = ecalloc(sizeof(char*), php_version_string_len);
snprintf(php_version_string, php_version_string_len, "%s%s", PHONGO_METADATA_PHP_VERSION_PREFIX, PHP_VERSION);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you're still missing the space that goes after the PHONGO_METADATA_PHP_VERSION_PREFIX + PHP_VERSION combo.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are indeed correct. This is an issue in libmongoc which seems to append platform data without a separating space. I'm working on a fix for that, but for the time being this PR will mitigate the issue.

[2021-02-17T13:57:57.155182+00:00] socket: TRACE > 00110: 2e 31 35 20 2f 20 6d 69 6e 65 20 63 66 67 3d 30 . 1 5 / m i n e c f g = 0

Since matching this is not trivial, we're happy matching the trailing space at
the end of each handshake data item.
Copy link
Member

Choose a reason for hiding this comment

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

The trailing space will ultimately be removed once you address a related ticket in libmongoc, correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it can be removed once we fix that.

@alcaeus alcaeus merged commit ef28066 into mongodb:v1.9 Feb 23, 2021
@alcaeus alcaeus deleted the phpc-1774 branch February 23, 2021 12:50
alcaeus added a commit that referenced this pull request Feb 23, 2021
* v1.9:
  PHPC-1739 Move from travis-ci to GitHub Actions (#1199)
  PHPC-1774 Fix truncation of PHP_VERSION constant in handshake metadata (#1202)
  PHPC-1775 Use correct size for strncpy in when initialising DBPointer (#1203)
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