-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
Fix null terminated string in Ruby wrapper type helper names #6370
Conversation
Is there any test for avoiding regression? |
No, I'm not sure what kind of test have in mind for this? |
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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protobuf/ruby/ext/google/protobuf_c/message.c
Line 295 in 8041dd4
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.
The problem here is writing the |
I see. Thought it was writing \0 before the last character. |
Fix for an error with the string terminator placement in #5739.
Thanks for pointing it out @tenderlove!