[libvirt] [PATCH] Fix potential use of undefined variable in remote dispatch code

From: "Daniel P. Berrange" <berrange@redhat.com> If an early dispatch check caused a jump to the 'cleanup' branch then virTypeParamsFree() would be called with an uninitialized 'nparams' variable. Fortunately 'params' is initialized to NULL, so the uninitialized 'nparams' variable would not be used. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/rpc/gendispatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 7b93062..8d3b013 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -495,7 +495,7 @@ elsif ($mode eq "server") { push(@args_list, "args->$1.$1_len"); } elsif ($args_member =~ m/^remote_typed_param (\S+)<(\S+)>;/) { push(@vars_list, "virTypedParameterPtr $1 = NULL"); - push(@vars_list, "int n$1"); + push(@vars_list, "int n$1 = 0;"); if ($call->{ProcName} eq "NodeSetMemoryParameters") { push(@args_list, "priv->conn"); } -- 1.8.2.1

On 05/02/2013 05:39 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
If an early dispatch check caused a jump to the 'cleanup' branch then virTypeParamsFree() would be called with an uninitialized 'nparams' variable. Fortunately 'params' is initialized to NULL, so the uninitialized 'nparams' variable would not be used.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/rpc/gendispatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ACK.
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 7b93062..8d3b013 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -495,7 +495,7 @@ elsif ($mode eq "server") { push(@args_list, "args->$1.$1_len"); } elsif ($args_member =~ m/^remote_typed_param (\S+)<(\S+)>;/) { push(@vars_list, "virTypedParameterPtr $1 = NULL"); - push(@vars_list, "int n$1"); + push(@vars_list, "int n$1 = 0;"); if ($call->{ProcName} eq "NodeSetMemoryParameters") { push(@args_list, "priv->conn"); }
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Daniel P. Berrange
-
Eric Blake