Avoid call to rb_string_value_cstr() which doesn't handle binary strings properly#35
Conversation
…ngs from Ruby properly Fixes buoyant-data#32
|
-2 yo shit do not build. ;) |
|
Travis can take a leap for now. Tyler, good approach. I'm wary of relying on Ruby to "do the right thing" On Wed, Sep 10, 2014 at 8:37 PM, R. Tyler Croy notifications@github.com
|
|
@stancampbell3 Most of what I found on the internet suggested this approach to safely handle binary data in C extensions 1, 2 (see attached patch file), 3 (the author isn't using the macro properly but it's effectively the same thing). The rb_string_value_cstr() function actually calls Between Ruby 1.8.7 and the master branch of the Ruby repo, the RSTRING_PTR macro hasn't actually changed which indicates to me that it's a stable API for C extensions to use. Using the buffer directly is safe IMO and obviates the need to create Ruby |
|
No, that does make sense. What I meant was back up in the Ruby VM, I'm The RSTRING_PTR On Wed, Sep 10, 2014 at 10:15 PM, R. Tyler Croy notifications@github.com
|
Avoid call to rb_string_value_cstr() which doesn't handle binary strings properly
I believe this is all that's necessary to resolve #32
I've done some manual testing to validate that we're sending the right bytes through Kafka, in the integration test I printed out the md5 of the byte string going in, and then printed the md5 of the buffer that a Kafka consumer (using the Java Kafka library) reads off:
producer side
consumer side