[PATCH nbdkit] Fix --dump-plugin on perl, python and ruby plugins.
Previously doing: nbdkit python --dump-plugin would segfault since the script was not loaded. It was possible to work around this using: nbdkit python test.py --dump-plugin assuming that you had a Python script to use. Change the code so that the original command (without the script name) doesn't segfault. --- plugins/perl/perl.c | 2 +- plugins/python/python.c | 2 +- plugins/ruby/ruby.c | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/perl/perl.c b/plugins/perl/perl.c index 80e5695..8d35b85 100644 --- a/plugins/perl/perl.c +++ b/plugins/perl/perl.c @@ -169,7 +169,7 @@ perl_dump_plugin (void) { dSP; - if (callback_defined ("dump_plugin")) { + if (script && callback_defined ("dump_plugin")) { ENTER; SAVETMPS; PUSHMARK (SP); diff --git a/plugins/python/python.c b/plugins/python/python.c index b105e53..83a32ea 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -155,7 +155,7 @@ py_dump_plugin (void) PyObject *fn; PyObject *r; - if (callback_defined ("dump_plugin", &fn)) { + if (script && callback_defined ("dump_plugin", &fn)) { PyErr_Clear (); r = PyObject_CallObject (fn, NULL); diff --git a/plugins/ruby/ruby.c b/plugins/ruby/ruby.c index 6b0285f..aa57f65 100644 --- a/plugins/ruby/ruby.c +++ b/plugins/ruby/ruby.c @@ -168,10 +168,8 @@ plugin_rb_unload (void) static void plugin_rb_dump_plugin (void) { - if (!script) { - nbdkit_error ("the first parameter must be script=/path/to/ruby/script.rb"); + if (!script) return; - } assert (code != NULL); -- 2.13.2
On 03/06/2018 07:15 AM, Richard W.M. Jones wrote:
Previously doing:
nbdkit python --dump-plugin
would segfault since the script was not loaded. It was possible to work around this using:
nbdkit python test.py --dump-plugin
assuming that you had a Python script to use.
Change the code so that the original command (without the script name) doesn't segfault. --- plugins/perl/perl.c | 2 +- plugins/python/python.c | 2 +- plugins/ruby/ruby.c | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-)
ACK -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
participants (2)
-
Eric Blake -
Richard W.M. Jones