# HG changeset patch # User root@hyperion.shrike # Node ID 9c5253e4b3a08afbc6c8bc46867fb9741d78cfa7 # Parent 94526250c762350accc9f9db23c125a218b618b7 Xen_OperatingSystem_setInstanceFromResource was crashing when the kernel path from libXen didn't look like it expected. This bug ensures that a faulty path will not crash the function. Signed-off-by : Rajagopalan Subrahmanian diff -r 94526250c762 -r 9c5253e4b3a0 src/Xen_OperatingSystem_Resource.c --- a/src/Xen_OperatingSystem_Resource.c Mon Dec 18 12:04:39 2006 -0700 +++ b/src/Xen_OperatingSystem_Resource.c Mon Dec 18 12:56:37 2006 -0500 @@ -15,7 +15,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // ============================================================================ // Authors: Dr. Gareth S. Bestor, -// Contributors: Jim Fehlig, +// Contributors: Jim Fehlig, , Raj Subrahmanian, name_label, CMPI_chars); - /* Set "OSType" = "LINUX" */ unsigned int ostype = 36; CMSetProperty(instance, "OSType", (CMPIValue *)&ostype, CMPI_uint16); - - /* Guess the OS version from the kernal filename. */ - char * version = (char *)(rindex(resource->kernel_kernel,'/')+1); - if (version == NULL) version = (char *)resource->kernel_kernel; + /* Guess the OS version from the kernal filename. If there is no / in the filename, just use the file name. If not, use the string following the last / */ + char * version = (char *)(rindex(resource->kernel_kernel,'/')); + if (version == NULL) version = (char *)resource->kernel_kernel; else version++; CMSetProperty(instance, "Version", (CMPIValue *)version, CMPI_chars); - /* Set the "Status" and "OperationalStatus" properties from the Xen domain state. */ switch (resource->power_state) { @@ -166,7 +163,6 @@ int Xen_OperatingSystem_setInstanceFromR CMSetProperty(instance, "Status",(CMPIValue *)"No Contact", CMPI_chars); break; } - CMSetArrayElementAt(status, 0, (CMPIValue *)&statusvalue, CMPI_uint16); CMSetProperty(instance, "OperationalStatus",(CMPIValue *)&status, CMPI_uint16A);