sh wrote:
Hi there, I need a little CMS wraper. I need decode S/MIME message chunk by chunk. I start make it based on cmsutil. But I receive "segmentation fault" every time on call NSS_CMSDecoder_Update. What's wrong?Without review your code, I would guess your problem may fall in one of 2 areas:
1) you are calling NSS_CMSDecoder_Update without properly setting up your context 2) (most likely) you are passing a C++ method as one or more of your callbacks.
You you build C++ wrappers for C API's, you need to pass a 'staging function' into C that can trampline you back to your C++ call method. C++ class methodes have an implicit 'This' pointer argument that you can't see, but is always there. If you need to get back to a full c++ method, you want to do something like the following:
class MyClass { public: static int cToCppTranslate_Doit(void *arg, int arg1, int arg2); private: int doit(arg1,arg2); } int MyClass::cToCppTranslate_Doit(void * arg, int arg1, int arg2) { MyClass *thisPtr = (MyClass *)arg; return thisPtr->doit(arg1, arg1); } MyClass::someOtherMyClassFunction() { . . CFuction_SetCallback(cToCppTranslateDoit, (void *) this); . . }The specifics varies. This requires that the callback can take application specific data that is passed back. Whether or not doit is really private is implemenation specific as well (it's not a problem for it to be public). It's also possible to cToCppTranslate_Doit() to be private, as long as it is always references from within a class. Be sure you understand why this works before you implement it. You need to be very familiar with how C++ and C works under the covers to do this trick.
bob
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto