Skip to content

Implement mysqlnd_set_persistent_string #7371

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 5 commits into from
Aug 20, 2021

Conversation

kamil-tekiela
Copy link
Member

See #7365

mnd_pefree(conn->authentication_plugin_data.s, conn->persistent);
conn->authentication_plugin_data.s = NULL;
}
mysqlnd_set_persistent_string(&conn->authentication_plugin_data, NULL, 0, conn->persistent);
conn->authentication_plugin_data.l = plugin_data_len;
conn->authentication_plugin_data.s = mnd_pemalloc(conn->authentication_plugin_data.l, conn->persistent);
memcpy(conn->authentication_plugin_data.s, plugin_data, plugin_data_len);
Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure If I can change this

Copy link
Member

Choose a reason for hiding this comment

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

pemalloc+memcpy is the same as pestrndup, so changing this should be fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I tried it but I get warnings because it is zend_uchar. I am not sure what is going on with this assignment so I will roll back this one change.

@kamil-tekiela kamil-tekiela marked this pull request as ready for review August 13, 2021 21:18

tmp = mnd_pestrdup(passwd, conn->persistent);
char * tmp = mnd_pestrdup(passwd, conn->persistent);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the conn->password assignment be changed as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's the non-N version. I wasn't sure if I can touch this given that it is a variable-length assignment and the previous code didn't set the .l property anywhere. Is it safe to use strlen() here?

Copy link
Member

Choose a reason for hiding this comment

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

pestrdup = pestrndup + strlen basically. You make a good point on this not assigning .l though (also applies to username assignment above), which seems suspect to me. I assume the length just never gets used?

Copy link
Member Author

Choose a reason for hiding this comment

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

I noticed there is passwd_len in the signature, so I used it. Is this ok?

I grepped for conn->password but I can't see any usage of this property. To be frank, I don't understand what is the purpose of these properties on the conn object. The connection seems to happen before they are saved. The change_user method also uses the values from the signature and then copies the strings.

Copy link
Member

Choose a reason for hiding this comment

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

Good point. Let's land this patch first and then remove them. I could see how they might be useful for a hypothetical "automatic reconnect" functionality, but given how such a functionality doesn't exist...

@kamil-tekiela kamil-tekiela merged commit a893a49 into php:master Aug 20, 2021
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