From: <mik...@us...> - 2008-10-29 22:28:38
|
Revision: 1139 http://omc.svn.sourceforge.net/omc/?rev=1139&view=rev Author: mike-brasher Date: 2008-10-29 22:28:30 +0000 (Wed, 29 Oct 2008) Log Message: ----------- New example to reproduce bug Added Paths: ----------- cmpi-bindings/trunk/test/cmpi/ cmpi-bindings/trunk/test/cmpi/Makefile cmpi-bindings/trunk/test/cmpi/README cmpi-bindings/trunk/test/cmpi/Thing.mof cmpi-bindings/trunk/test/cmpi/Thing.reg cmpi-bindings/trunk/test/cmpi/ThingProvider.c cmpi-bindings/trunk/test/cmpi/libThingProvider.so Added: cmpi-bindings/trunk/test/cmpi/Makefile =================================================================== --- cmpi-bindings/trunk/test/cmpi/Makefile (rev 0) +++ cmpi-bindings/trunk/test/cmpi/Makefile 2008-10-29 22:28:30 UTC (rev 1139) @@ -0,0 +1,29 @@ +TARGET = libThingProvider.so + +SOURCES = ThingProvider.c + +OBJECTS = $(SOURCES:.c=.o) + +INCLUDES += -I/usr/include/cmpi + +#LIBRARIES += -lkonkret + +FLAGS = -g -Wall -O2 -fPIC + +all: + echo $(OBJECTS) + gcc $(FLAGS) -c $(INCLUDES) ThingProvider.c + gcc $(FLAGS) -shared -o $(TARGET) $(INCLUDES) $(OBJECTS) $(LIBRARIES) + +clean: + rm -rf $(TARGET) + +install: + su -c "make install-su" + +install-su: + cp $(TARGET) /usr/lib64 + cp Thing.mof /var/lib/sfcb/stage/mofs/root/cimv2 + cp Thing.mof /var/lib/sfcb/stage/mofs/root/interop + cp Thing.reg /var/lib/sfcb/stage/regs + sfcbrepos -f Added: cmpi-bindings/trunk/test/cmpi/README =================================================================== --- cmpi-bindings/trunk/test/cmpi/README (rev 0) +++ cmpi-bindings/trunk/test/cmpi/README 2008-10-29 22:28:30 UTC (rev 1139) @@ -0,0 +1,7 @@ +This provider was written to reproduce a bug in SFCBD. By setting a string +property (Thing.message) to type string[], we crash sfcb. To reproduce: + + 1. Build provider (make) + 2. Install and register with sfcbd (make install) + 3. Do a enumerate-instances on Test_Thing from client. + Added: cmpi-bindings/trunk/test/cmpi/Thing.mof =================================================================== --- cmpi-bindings/trunk/test/cmpi/Thing.mof (rev 0) +++ cmpi-bindings/trunk/test/cmpi/Thing.mof 2008-10-29 22:28:30 UTC (rev 1139) @@ -0,0 +1,11 @@ +[ Description("Instance provider test reproduce crash in SFCBD")] +class Test_Thing +{ + [Key] string id; + uint32 count; + boolean flag; + string message; + uint32 counts[]; + boolean flags[]; + string messages[]; +}; Added: cmpi-bindings/trunk/test/cmpi/Thing.reg =================================================================== --- cmpi-bindings/trunk/test/cmpi/Thing.reg (rev 0) +++ cmpi-bindings/trunk/test/cmpi/Thing.reg 2008-10-29 22:28:30 UTC (rev 1139) @@ -0,0 +1,5 @@ +[Test_Thing] + provider: ThingProvider + location: ThingProvider + type: instance + namespace: root/cimv2 Added: cmpi-bindings/trunk/test/cmpi/ThingProvider.c =================================================================== --- cmpi-bindings/trunk/test/cmpi/ThingProvider.c (rev 0) +++ cmpi-bindings/trunk/test/cmpi/ThingProvider.c 2008-10-29 22:28:30 UTC (rev 1139) @@ -0,0 +1,157 @@ +#include <cmpi/cmpidt.h> +#include <cmpi/cmpimacs.h> + +static const CMPIBroker* _broker = NULL; + +static void ThingInitialize() +{ +} + +static CMPIStatus ThingCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus ThingEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIArray* _make_string_array() +{ + CMPIStatus st; + CMPIValue value; + CMPIArray* arr; + + arr = CMNewArray(_broker, 3, CMPI_string, &st); + + if (!arr || st.rc) + return arr; + + value.string = CMNewString(_broker, "RED", NULL); + CMSetArrayElementAt(arr, 0, &value, CMPI_string); + + value.string = CMNewString(_broker, "GREEN", NULL); + CMSetArrayElementAt(arr, 1, &value, CMPI_string); + + value.string = CMNewString(_broker, "BLUE", NULL); + CMSetArrayElementAt(arr, 2, &value, CMPI_string); + + return arr; +} + +static CMPIStatus ThingEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + CMPIInstance* inst; + CMPIObjectPath* tcop; + CMPIStatus st; + CMPIValue value; + + /* Create object path */ + + tcop = CMNewObjectPath(_broker, "root/cimv2", "Test_Thing", &st); + + if (!tcop || st.rc) + CMReturn(CMPI_RC_ERR_FAILED); + + st = CMAddKey(tcop, "id", (const CMPIValue*)"RED", CMPI_chars); + + if (st.rc) + CMReturn(CMPI_RC_ERR_FAILED); + + /* Create instance */ + + inst = CMNewInstance(_broker, tcop, &st); + + if (!inst || st.rc) + CMReturn(CMPI_RC_ERR_FAILED); + + st = CMSetProperty(inst, "id", (const CMPIValue*)"RED", CMPI_chars); + + if (st.rc) + CMReturn(CMPI_RC_ERR_FAILED); + + value.array = _make_string_array(); + + /* ATTN: by setting a string property to a string[], we cause a SIGSEGV + * in SFCBD. + */ + + st = CMSetProperty(inst, "message", &value, CMPI_ARRAY|CMPI_string); + + if (st.rc) + CMReturn(CMPI_RC_ERR_FAILED); + + CMReturnInstance(cr, inst); + + CMReturn(CMPI_RC_OK); +} + +CMPIStatus ThingGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* result, + const CMPIObjectPath* cop, + const char** properties) +{ + CMReturn(CMPI_RC_ERR_NOT_FOUND); +} + +static CMPIStatus ThingCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus ThingModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char** properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus ThingDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus ThingExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +CMInstanceMIStub( + Thing, + ThingProvider, + _broker, + ThingInitialize()) Added: cmpi-bindings/trunk/test/cmpi/libThingProvider.so =================================================================== (Binary files differ) Property changes on: cmpi-bindings/trunk/test/cmpi/libThingProvider.so ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |