Bug 189345: we incorrectly assumed that a C_XxxFinal call to determine the

length of the buffer would also terminate the active operation if the
buffer length is 0.  PKCS#11 says it doesn't, so we need to make the
additional C_XxxFinal call even if the buffer length is 0.  Allocate a
buffer from the heap if the stack buffer is too small and free the
heap-allocated buffer before we return from pk11_Finalize.  We can use the
stack buffer if count is equal to its size.


git-svn-id: svn://10.0.0.236/trunk@136742 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
wtc%netscape.com
2003-01-21 19:33:24 +00:00
parent 32b5a49d0b
commit 73bb8966c6

View File

@@ -4122,6 +4122,9 @@ finalize:
}
if (crv != CKR_OK) {
if (buffer != stackBuf) {
PORT_Free(buffer);
}
if (crv == CKR_OPERATION_NOT_INITIALIZED) {
/* if there's no operation, it is finalized */
return SECSuccess;
@@ -4131,13 +4134,20 @@ finalize:
}
/* try to finalize the session with a buffer */
if (buffer == NULL && count > 0) {
if (count < sizeof stackBuf) {
if (buffer == NULL) {
if (count <= sizeof stackBuf) {
buffer = stackBuf;
goto finalize;
} else {
return SECFailure;
buffer = PORT_Alloc(count);
if (buffer == NULL) {
PORT_SetError(SEC_ERROR_NO_MEMORY);
return SECFailure;
}
}
goto finalize;
}
if (buffer != stackBuf) {
PORT_Free(buffer);
}
return SECSuccess;
}