From 56826a0dc9533cb1d7d227c5a2f70d8d31a4dd8f Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Fri, 24 Apr 2009 14:31:38 +0100 Subject: [PATCH] Ruby bindings didn't NULL-terminate an array, resulting in segfault. --- ruby/ext/guestfs/_guestfs.c | 5 +++++ src/generator.ml | 1 + 2 files changed, 6 insertions(+) diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c index 07b0228..d4b62ca 100644 --- a/ruby/ext/guestfs/_guestfs.c +++ b/ruby/ext/guestfs/_guestfs.c @@ -1418,6 +1418,7 @@ static VALUE ruby_guestfs_vgcreate (VALUE gv, VALUE volgroupv, VALUE physvolsv) VALUE v = rb_ary_entry (physvolsv, i); physvols[i] = StringValueCStr (v); } + physvols[len] = NULL; } int r; @@ -1503,6 +1504,7 @@ static VALUE ruby_guestfs_sfdisk (VALUE gv, VALUE devicev, VALUE cylsv, VALUE he VALUE v = rb_ary_entry (linesv, i); lines[i] = StringValueCStr (v); } + lines[len] = NULL; } int r; @@ -1659,6 +1661,7 @@ static VALUE ruby_guestfs_command (VALUE gv, VALUE argumentsv) VALUE v = rb_ary_entry (argumentsv, i); arguments[i] = StringValueCStr (v); } + arguments[len] = NULL; } char *r; @@ -1688,6 +1691,7 @@ static VALUE ruby_guestfs_command_lines (VALUE gv, VALUE argumentsv) VALUE v = rb_ary_entry (argumentsv, i); arguments[i] = StringValueCStr (v); } + arguments[len] = NULL; } char **r; @@ -2337,6 +2341,7 @@ static VALUE ruby_guestfs_debug (VALUE gv, VALUE subcmdv, VALUE extraargsv) VALUE v = rb_ary_entry (extraargsv, i); extraargs[i] = StringValueCStr (v); } + extraargs[len] = NULL; } char *r; diff --git a/src/generator.ml b/src/generator.ml index 29b0ecd..19ee71a 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -5414,6 +5414,7 @@ static VALUE ruby_guestfs_close (VALUE gv) pr " VALUE v = rb_ary_entry (%sv, i);\n" n; pr " %s[i] = StringValueCStr (v);\n" n; pr " }\n"; + pr " %s[len] = NULL;\n" n; pr " }\n"; | Bool n | Int n -> -- 1.8.3.1