Fiddle possibly misuses mprotect
Coverity Scan found a possible bug in "initialize" function of ext/fiddle/closure.c:
result = ffi_prep_closure(pcl, cif, callback, (void *)self);
i = mprotect(pcl, sizeof(pcl), PROT_READ | PROT_EXEC)
I don't understand the code completely, but the size of the pointer does not seem to make sense.
Perhaps, "sizeof(pcl)" should be "sizeof(*pcl)".
The same applies to dealloc:
BTW, ffi_prep_closure seems deprecated.
We should use ffi_prep_closure_loc instead when it is available.
Yusuke Endoh email@example.com
#2 [ruby-core:60179] Updated by tenderlovemaking (Aaron Patterson) over 3 years ago
I took the mprotect example from the ffi man pages. Seems there must be a bug in the example code. Anyway, I've fixed it.
Also, we should be using
ffi_prep_closure_loc if it is available: