Rolando Abarca
7/19/2008 9:55:00 PM
On 19-07-2008, at 17:01, Daniel Kaminski wrote:
> Rolando Abarca wrote:
>> On 19-07-2008, at 15:36, Daniel Kaminski wrote:
>>
>>> That's me again, now i know that i have to terminate an array with
>>> null
>>> pointer, is this possible in ruby?
>>
>> NULL is just a 0 (zero):
>>
>> $ ruby -e "syscall(11, '/home/rolando/test.rb', ['true', 'lala',
>> 0].pack('ppi'), ['X=1', 0].pack('pi'))"
>> ["lala"]
>> {"X"=>"1"}
>>
>> $ cat test.rb
>> #!/usr/local/bin/ruby
>>
>> p ARGV
>> p ENV
>
>
> -e:1:in `syscall': string contains null byte (ArgumentError)
> from -e:1
>
> It's the same error when tried ['true', nil].pack('p*'), result is the
> same too, it adds '000\000\000\000'.
> Do you have patched ruby build or something? i managed to make it work
> by commenting few lines from string.c responsible for above exception.
>
> regards:-)
I think you're missing the fact that I used 'ppi' as the argument to
pack (NULL is an integer) and not 'p*'.
regards,
--
Rolando Abarca M.