aboutsummaryrefslogtreecommitdiffstats
path: root/ext/fiddle
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-10 18:35:21 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-10 18:35:21 +0000
commit2570f838da7ca82d586304d4669de49ced758bb6 (patch)
treecbb31b3dea020f47574baf023caf20d9e0dde77b /ext/fiddle
parent3f9e0e43c3a8f5db37f671ad3f957e4fddba0bcb (diff)
downloadruby-2570f838da7ca82d586304d4669de49ced758bb6.tar.gz
* ext/fiddle/closure.c (initialize): check mprotect's return value.
If mprotect is failed because of PaX or something, its function call will cause SEGV. http://c5664.rubyci.org/~chkbuild/ruby-trunk/log/20130401T210301Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/fiddle')
-rw-r--r--ext/fiddle/closure.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c
index fdb2233b22..d064f11991 100644
--- a/ext/fiddle/closure.c
+++ b/ext/fiddle/closure.c
@@ -228,7 +228,10 @@ initialize(int rbargc, VALUE argv[], VALUE self)
#else
result = ffi_prep_closure(pcl, cif, callback, (void *)self);
cl->code = (void *)pcl;
- mprotect(pcl, sizeof(pcl), PROT_READ | PROT_EXEC);
+ i = mprotect(pcl, sizeof(pcl), PROT_READ | PROT_EXEC);
+ if (i) {
+ rb_sys_fail("mprotect");
+ }
#endif
if (FFI_OK != result)