summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-14 14:47:14 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-14 14:47:14 +0000
commitaa69372cf806f77c8dd9947eda4662305bb6b12f (patch)
treeeb275b44d7d85ba622dd9b8fe303d8d3c536f256 /ext
parent5e17378c440a5e5b1a81ff77fea5064ec438e443 (diff)
merge revision(s) 40216: [Backport #8266]
* 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/branches/ruby_2_0_0@40290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-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)