THRIFT-1400. rb: Ruby native extension aborts with __stack_chk_fail in OSX

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1188248 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/ext/struct.c b/lib/rb/ext/struct.c
index 590983f..8234573 100644
--- a/lib/rb/ext/struct.c
+++ b/lib/rb/ext/struct.c
@@ -231,10 +231,10 @@
 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_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);
 }