You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by br...@apache.org on 2011/10/24 19:29:16 UTC

svn commit: r1188248 - /thrift/trunk/lib/rb/ext/struct.c

Author: bryanduxbury
Date: Mon Oct 24 17:29:16 2011
New Revision: 1188248

URL: http://svn.apache.org/viewvc?rev=1188248&view=rev
Log:
THRIFT-1400. rb: Ruby native extension aborts with __stack_chk_fail in OSX

Modified:
    thrift/trunk/lib/rb/ext/struct.c

Modified: thrift/trunk/lib/rb/ext/struct.c
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/ext/struct.c?rev=1188248&r1=1188247&r2=1188248&view=diff
==============================================================================
--- thrift/trunk/lib/rb/ext/struct.c (original)
+++ thrift/trunk/lib/rb/ext/struct.c Mon Oct 24 17:29:16 2011
@@ -231,10 +231,10 @@ static VALUE rb_thrift_struct_write(VALU
 static void write_anything(int ttype, VALUE value, VALUE protocol, VALUE field_info);
 
 VALUE get_field_value(VALUE obj, VALUE field_name) {
-  char name_buf[RSTRING_LEN(field_name) + 1];
+  char name_buf[RSTRING_LEN(field_name) + 2];
 
   name_buf[0] = '@';
-  strlcpy(&name_buf[1], RSTRING_PTR(field_name), sizeof(name_buf));
+  strlcpy(&name_buf[1], RSTRING_PTR(field_name), RSTRING_LEN(field_name) + 1);
 
   VALUE value = rb_ivar_get(obj, rb_intern(name_buf));
 
@@ -417,10 +417,10 @@ static void skip_map_contents(VALUE prot
 static void skip_list_or_set_contents(VALUE protocol, VALUE element_type_value, int size);
 
 static void set_field_value(VALUE obj, VALUE field_name, VALUE value) {
-  char name_buf[RSTRING_LEN(field_name) + 1];
+  char name_buf[RSTRING_LEN(field_name) + 2];
 
   name_buf[0] = '@';
-  strlcpy(&name_buf[1], RSTRING_PTR(field_name), sizeof(name_buf));
+  strlcpy(&name_buf[1], RSTRING_PTR(field_name), RSTRING_LEN(field_name)+1);
 
   rb_ivar_set(obj, rb_intern(name_buf), value);
 }