"DECODE_BUF_NOFAIL" failure
"Nord, John D Contractor/NCCIM" <[email protected]> Tue, 12 Sep 2000 16:02:30 -0500
| Newsgroups | gmane.ietf.sfl |
|---|---|
| Message-ID | <1345B59AC3C5D211975E00A0C99DAC7A01B67551@exch-msg-6> |
All,
I am using the SFL/SNACC libraries to parse a P7M format file. I was
having a problem opening a somewhat large P7M file (the file I was parsing was
208K). The call stack to where I got an error is:
- CSM_MsgToVerify::PreProc(CSMIME *, CSM_Buffer *,
CSM_ListC<CSM_RecipientIdentifier> *)
- CSM_MsgToVerify::PreProc(CSM_Buffer *)
- CSM_DataToVerify::PreProc(CSM_Buffer *)
- SME(DECODE_BUF_NOFAIL(m_pSnaccSignedData, pEncodedBlob, status))
The last line, the call to the macro "DECODE_BUF_NOFAIL", created an exception
when the free() was called at the end of the macro. It looks like this macro
will not handle a buffer that is bigger than VDASNACC_ENCDEC_BUFSIZE (100000).
It would be nice if inside the macro (in "sm_vdasnacc.h"), the constant
VDASNACC_ENCDEC_BUFSIZE could be changed to (blob)->Length(), such that the new
macro looks like:
#define DECODE_BUF_NOFAIL(decodeData, blob, status)\
{\
char *pchBuffer = (char *)calloc(1, \
(blob)->Length());\
size_t encodedLen;\
AsnBuf outputBuf;\
int nDecStatus = 0;\
\
outputBuf.Init(pchBuffer, (blob)->Length());\
outputBuf.ResetInWriteRvsMode();\
SM_WriteToAsnBuf((blob), outputBuf);\
outputBuf.ResetInReadMode();\
if ((nDecStatus = (decodeData)->BDecPdu(outputBuf, encodedLen)) == false)\
status = 1;\
else\
status = 0;\
free(pchBuffer);\
}
However, this doesn't work, because the macro is called with both a CSM_Buffer
pointer and a CSM_Buffer reference in various places.
In order to make this macro work for CSM_Buffer's that are bigger than
VDASNACC_ENCDEC_BUFSIZE, one of a few things is going to have to happen:
(1) - the macro could be split into 2 macros, one that works for
CSM_Buffer pointers [(blob)->Length()] and one that works for CSM_Buffer
references [(blob).Length()].
(2) - the change could be made to the macro as shown above, and all
calls to the macro in the SFL that currently call it with a CSM_Buffer reference
could be changed to call the macro with a CSM_Buffer pointer.
(3) - an argument could be added to the macro that specifies the length
of the data in 'blob', and that length could take the place of
VDASNACC_ENCDEC_BUFSIZE in the macro definition.
I'm not sure how I'm going to handle this. Any of these proposed
changes would cause a lot of small changes all over the SFL. Does anyone have a
different/better idea?
Thanks,
John Nord