Sha256: 08bfd73617c26a5710e1ac13be1c1929c8e7cbdfbf8596ffc5952c796287884a
Contents?: true
Size: 1015 Bytes
Versions: 1
Compression:
Stored size: 1015 Bytes
Contents
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper")) describe "String tests" do include FFI module LibTest extend FFI::Library ffi_lib TestLibrary::PATH attach_function :ptr_ret_pointer, [ :pointer, :int], :string attach_function :string_equals, [ :string, :string ], :int end it "MemoryPointer#get_string returns a tainted string" do mp = MemoryPointer.new 1024 mp.put_string(0, "test\0") str = mp.get_string(0) str.tainted?.should == true end it "String returned by a method is tainted" do mp = MemoryPointer.new :pointer sp = MemoryPointer.new 1024 sp.put_string(0, "test") mp.put_pointer(0, sp) str = LibTest.ptr_ret_pointer(mp, 0) str.should == "test" str.tainted?.should == true end it "Tainted String parameter should throw a SecurityError" do $SAFE = 1 str = "test" str.taint begin LibTest.string_equals(str, str).should == false rescue SecurityError => e end end if false end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ffi-0.2.0 | specs/string_spec.rb |