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

Fix null terminated string in Ruby wrapper type helper names #6370

Merged
merged 1 commit into from
Jul 23, 2019

Conversation

jbolinger
Copy link
Contributor

Fix for an error with the string terminator placement in #5739.

Thanks for pointing it out @tenderlove!

@TeBoring
Copy link
Contributor

Is there any test for avoiding regression?

@jbolinger
Copy link
Contributor Author

No, I'm not sure what kind of test have in mind for this?

@TeBoring
Copy link
Contributor

Why previously this hasn't broken anything?

@@ -192,7 +192,7 @@ static int extract_method_call(VALUE method_name, MessageHeader* self,
// Find the field name
char wrapper_field_name[name_len - 8];
strncpy(wrapper_field_name, name, name_len - 9);
wrapper_field_name[name_len - 7] = '\0';
wrapper_field_name[name_len - 9] = '\0';
Copy link
Contributor

Choose a reason for hiding this comment

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

if (accessor_type == METHOD_UNKNOWN || (o == NULL && f == NULL) ) {

Previously, it should be interpreted as METHOD_UNKNOWN. Then, the value will be set to the parent ruby object.
I guess, if you actually encode the message then, the value you set won't appear in the encoding result.

@jbolinger
Copy link
Contributor Author

The problem here is writing the \0 at wrapper_field_name[name_len - 7] is out of bounds for the variable declared as char wrapper_field_name[name_len - 8]; True, it doesn't seem to have caused problems in the past for whatever reason though.

@TeBoring
Copy link
Contributor

I see. Thought it was writing \0 before the last character.

@TeBoring TeBoring merged commit 180d3e3 into protocolbuffers:master Jul 23, 2019
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.

4 participants