alien.libraries, stack-checker.alien: check user inputs more carefully to ensure that invalid ABI descriptors don't slip through and break random stuff (reported by prunedtree)
parent
ea726f5680
commit
1834241e5a
|
@ -1,7 +1,8 @@
|
||||||
! Copyright (C) 2009, 2010 Slava Pestov, Joe Groff.
|
! Copyright (C) 2009, 2010 Slava Pestov, Joe Groff.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien alien.strings assocs io.backend
|
USING: accessors alien alien.strings assocs io.backend
|
||||||
kernel namespaces destructors sequences system io.pathnames ;
|
kernel namespaces destructors sequences strings
|
||||||
|
system io.pathnames ;
|
||||||
IN: alien.libraries
|
IN: alien.libraries
|
||||||
|
|
||||||
: dlopen ( path -- dll ) native-string>alien (dlopen) ;
|
: dlopen ( path -- dll ) native-string>alien (dlopen) ;
|
||||||
|
@ -12,7 +13,7 @@ SYMBOL: libraries
|
||||||
|
|
||||||
libraries [ H{ } clone ] initialize
|
libraries [ H{ } clone ] initialize
|
||||||
|
|
||||||
TUPLE: library path abi dll ;
|
TUPLE: library { path string } { abi abi initial: cdecl } dll ;
|
||||||
|
|
||||||
ERROR: no-library name ;
|
ERROR: no-library name ;
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,13 @@ SPECIALIZED-ARRAY: float
|
||||||
SPECIALIZED-ARRAY: char
|
SPECIALIZED-ARRAY: char
|
||||||
IN: compiler.tests.alien
|
IN: compiler.tests.alien
|
||||||
|
|
||||||
|
! Make sure that invalid inputs don't pass the stack checker
|
||||||
|
[ [ void { } "cdecl" alien-indirect ] infer ] must-fail
|
||||||
|
[ [ "void" { } cdecl alien-indirect ] infer ] must-fail
|
||||||
|
[ [ void* 3 cdecl alien-indirect ] infer ] must-fail
|
||||||
|
[ [ void* { "int" } cdecl alien-indirect ] infer ] must-fail
|
||||||
|
[ [ void* { int } cdecl { } alien-callback ] infer ] must-fail
|
||||||
|
|
||||||
<<
|
<<
|
||||||
: libfactor-ffi-tests-path ( -- string )
|
: libfactor-ffi-tests-path ( -- string )
|
||||||
"resource:" absolute-path
|
"resource:" absolute-path
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
! Copyright (C) 2008, 2010 Slava Pestov.
|
! Copyright (C) 2008, 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel sequences accessors combinators math namespaces
|
USING: kernel arrays sequences accessors combinators math
|
||||||
init sets words assocs alien.libraries alien alien.private
|
namespaces init sets words assocs alien.libraries alien
|
||||||
alien.c-types fry quotations stack-checker.backend
|
alien.private alien.c-types fry quotations strings
|
||||||
stack-checker.errors stack-checker.visitor
|
stack-checker.backend stack-checker.errors stack-checker.visitor
|
||||||
stack-checker.dependencies compiler.utilities ;
|
stack-checker.dependencies compiler.utilities ;
|
||||||
IN: stack-checker.alien
|
IN: stack-checker.alien
|
||||||
|
|
||||||
TUPLE: alien-node-params return parameters abi in-d out-d ;
|
TUPLE: alien-node-params
|
||||||
|
return parameters
|
||||||
|
{ abi abi initial: cdecl }
|
||||||
|
in-d
|
||||||
|
out-d ;
|
||||||
|
|
||||||
TUPLE: alien-invoke-params < alien-node-params library function ;
|
TUPLE: alien-invoke-params < alien-node-params library { function string } ;
|
||||||
|
|
||||||
TUPLE: alien-indirect-params < alien-node-params ;
|
TUPLE: alien-indirect-params < alien-node-params ;
|
||||||
|
|
||||||
TUPLE: alien-assembly-params < alien-node-params quot ;
|
TUPLE: alien-assembly-params < alien-node-params { quot quotation } ;
|
||||||
|
|
||||||
TUPLE: alien-callback-params < alien-node-params quot xt ;
|
TUPLE: alien-callback-params < alien-node-params { quot quotation } xt ;
|
||||||
|
|
||||||
: param-prep-quot ( params -- quot )
|
: param-prep-quot ( params -- quot )
|
||||||
parameters>> [ c-type c-type-unboxer-quot ] map spread>quot ;
|
parameters>> [ c-type c-type-unboxer-quot ] map spread>quot ;
|
||||||
|
|
Loading…
Reference in New Issue