From 90763e04ba2200f96a485d2ef3bb56817ae1b2db Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Thu, 20 Jun 2024 13:25:30 -0400 Subject: Load external GC using command line argument This commit changes the external GC to be loaded with the `--gc-library` command line argument instead of the RUBY_GC_LIBRARY_PATH environment variable because @nobu pointed out that loading binaries using environment variables can pose a security risk. --- ruby.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index b452b0b1ef..fa64dc3caa 100644 --- a/ruby.c +++ b/ruby.c @@ -1435,6 +1435,16 @@ proc_long_options(ruby_cmdline_options_t *opt, const char *s, long argc, char ** else if (is_option_with_arg("source-encoding", Qfalse, Qtrue)) { set_source_encoding_once(opt, s, 0); } +#endif +#if defined(USE_SHARED_GC) && USE_SHARED_GC + else if (is_option_with_arg("gc-library", Qfalse, Qfalse)) { + // no-op + // Handled by ruby_load_external_gc_from_argv + + if (!dln_supported_p()) { + rb_warn("--gc-library is ignored because this executable file can't load extension libraries"); + } + } #endif else if (strcmp("version", s) == 0) { if (envopt) goto noenvopt_long; -- cgit v1.2.3