[Libvirt-cim] [PATCH] Do not pass NULL to strchr()

Jim Fehlig jfehlig at novell.com
Tue Mar 3 16:05:54 UTC 2009


# HG changeset patch
# User Jim Fehlig <jfehlig at novell.com>
# Date 1236099840 25200
# Node ID e3dd4cec1b61373e738fe3ba58557ae543b41789
# Parent  8e4577bb3b3a6e1af8dbcf1887641571b0cfdedb
Do not pass NULL to strchr()

get_typed_class() in libxkutil can segfault a provider if refcn
parameter is NULL.  Ensure refcn is non-NULL before subsequent use.

    Signed-off-by: Jim Fehlig <jfehlig at novell.com>

diff -r 8e4577bb3b3a -r e3dd4cec1b61 libxkutil/misc_util.c
--- a/libxkutil/misc_util.c	Fri Feb 27 18:08:06 2009 -0300
+++ b/libxkutil/misc_util.c	Tue Mar 03 10:04:00 2009 -0700
@@ -218,6 +218,9 @@ char *get_typed_class(const char *refcn,
         char *class = NULL;
         char *pfx;
 
+        if (refcn == NULL)
+                return NULL;
+
         if (strchr(refcn, '_'))
                 pfx = class_prefix_name(refcn);
         else




More information about the Libvirt-cim mailing list