security/nss/lib/libpkix/pkix/util/pkix_errpaths.c

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4 /*
michael@0 5 * pkix_errpaths.c
michael@0 6 *
michael@0 7 * Error Handling Helper Functions
michael@0 8 *
michael@0 9 */
michael@0 10
michael@0 11 #define PKIX_STDVARS_POINTER
michael@0 12 #include "pkix_error.h"
michael@0 13
michael@0 14 const PKIX_StdVars zeroStdVars;
michael@0 15
michael@0 16 PKIX_Error*
michael@0 17 PKIX_DoThrow(PKIX_StdVars * stdVars, PKIX_ERRORCLASS errClass,
michael@0 18 PKIX_ERRORCODE errCode, PKIX_ERRORCLASS overrideClass,
michael@0 19 void *plContext)
michael@0 20 {
michael@0 21 if (!pkixErrorReceived && !pkixErrorResult && pkixErrorList) {
michael@0 22 pkixTempResult = PKIX_List_GetItem(pkixErrorList, 0,
michael@0 23 (PKIX_PL_Object**)&pkixReturnResult,
michael@0 24 plContext);
michael@0 25 } else {
michael@0 26 pkixTempResult = (PKIX_Error*)pkix_Throw(errClass, myFuncName, errCode,
michael@0 27 overrideClass, pkixErrorResult,
michael@0 28 &pkixReturnResult, plContext);
michael@0 29 }
michael@0 30 if (pkixReturnResult) {
michael@0 31 if (pkixErrorResult != PKIX_ALLOC_ERROR()) {
michael@0 32 PKIX_DECREF(pkixErrorResult);
michael@0 33 }
michael@0 34 pkixTempResult = pkixReturnResult;
michael@0 35 } else if (pkixErrorResult) {
michael@0 36 if (pkixTempResult != PKIX_ALLOC_ERROR()) {
michael@0 37 PKIX_DECREF(pkixTempResult);
michael@0 38 }
michael@0 39 pkixTempResult = pkixErrorResult;
michael@0 40 }
michael@0 41 if (pkixErrorList) {
michael@0 42 PKIX_PL_Object_DecRef((PKIX_PL_Object*)pkixErrorList, plContext);
michael@0 43 pkixErrorList = NULL;
michael@0 44 }
michael@0 45 return pkixTempResult;
michael@0 46 }
michael@0 47
michael@0 48 PKIX_Error *
michael@0 49 PKIX_DoReturn(PKIX_StdVars * stdVars, PKIX_ERRORCLASS errClass,
michael@0 50 PKIX_Boolean doLogger, void *plContext)
michael@0 51 {
michael@0 52 PKIX_OBJECT_UNLOCK(lockedObject);
michael@0 53 if (pkixErrorReceived || pkixErrorResult || pkixErrorList)
michael@0 54 return PKIX_DoThrow(stdVars, errClass, pkixErrorCode, pkixErrorClass,
michael@0 55 plContext);
michael@0 56 /* PKIX_DEBUG_EXIT(type); */
michael@0 57 if (doLogger)
michael@0 58 _PKIX_DEBUG_TRACE(pkixLoggersDebugTrace, "<<<", PKIX_LOGGER_LEVEL_TRACE);
michael@0 59 return NULL;
michael@0 60 }
michael@0 61
michael@0 62 /* PKIX_DoAddError - creates the list of received error if it does not exist
michael@0 63 * yet and adds newly received error into the list. */
michael@0 64 void
michael@0 65 PKIX_DoAddError(PKIX_StdVars *stdVars, PKIX_Error *error, void * plContext)
michael@0 66 {
michael@0 67 PKIX_List *localList = NULL;
michael@0 68 PKIX_Error *localError = NULL;
michael@0 69 PKIX_Boolean listCreated = PKIX_FALSE;
michael@0 70
michael@0 71 if (!pkixErrorList) {
michael@0 72 localError = PKIX_List_Create(&localList, plContext);
michael@0 73 if (localError)
michael@0 74 goto cleanup;
michael@0 75 listCreated = PKIX_TRUE;
michael@0 76 } else {
michael@0 77 localList = pkixErrorList;
michael@0 78 }
michael@0 79
michael@0 80 localError = PKIX_List_AppendItem(localList, (PKIX_PL_Object*)error,
michael@0 81 plContext);
michael@0 82 PORT_Assert (localError == NULL);
michael@0 83 if (localError != NULL) {
michael@0 84 if (listCreated) {
michael@0 85 /* ignore the error code of DecRef function */
michael@0 86 PKIX_PL_Object_DecRef((PKIX_PL_Object*)localList, plContext);
michael@0 87 localList = NULL;
michael@0 88 }
michael@0 89 } else {
michael@0 90 pkixErrorList = localList;
michael@0 91 }
michael@0 92
michael@0 93 cleanup:
michael@0 94
michael@0 95 if (localError && localError != PKIX_ALLOC_ERROR()) {
michael@0 96 PKIX_PL_Object_DecRef((PKIX_PL_Object*)localError, plContext);
michael@0 97 }
michael@0 98
michael@0 99 if (error && error != PKIX_ALLOC_ERROR()) {
michael@0 100 PKIX_PL_Object_DecRef((PKIX_PL_Object*)error, plContext);
michael@0 101 }
michael@0 102 }
michael@0 103

mercurial