[ 
https://issues.apache.org/jira/browse/THRIFT-1047?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12987383#action_12987383
 ] 

Jake Donham commented on THRIFT-1047:
-------------------------------------

There is no checking higher up in the call chain (e.g. when you create a Thrift 
struct with a field of type string), so it is easy to pass a non-string by 
accident.

An alternative would be to check the type of str in 
BinaryProtocol#write_string, which would avoid the check in other calls to 
write (when the argument is certain to be a string).

Another alternative would be to check the type in the generated stubs when a 
field of type string is set.

> rb_thrift_memory_buffer_write treats arg as string without check, segfaults 
> if you pass non-string
> --------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-1047
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1047
>             Project: Thrift
>          Issue Type: Bug
>          Components: Ruby - Library
>    Affects Versions: 0.5
>            Reporter: Jake Donham
>
> I think there should be a call to Check_Type(str, T_STRING) in there
> VALUE rb_thrift_memory_buffer_write(VALUE self, VALUE str) {
>   VALUE buf = GET_BUF(self);
>   rb_str_buf_cat(buf, RSTRING_PTR(str), RSTRING_LEN(str));
>   return Qnil;
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to