summaryrefslogtreecommitdiff
path: root/security/nss/lib/libpkix
diff options
context:
space:
mode:
Diffstat (limited to 'security/nss/lib/libpkix')
-rwxr-xr-xsecurity/nss/lib/libpkix/include/pkix_util.h19
-rwxr-xr-xsecurity/nss/lib/libpkix/include/pkixt.h4
-rw-r--r--security/nss/lib/libpkix/pkix/util/pkix_logger.c96
-rw-r--r--security/nss/lib/libpkix/pkix/util/pkix_logger.h4
4 files changed, 46 insertions, 77 deletions
diff --git a/security/nss/lib/libpkix/include/pkix_util.h b/security/nss/lib/libpkix/include/pkix_util.h
index b2a8df42b..6357fcadb 100755
--- a/security/nss/lib/libpkix/include/pkix_util.h
+++ b/security/nss/lib/libpkix/include/pkix_util.h
@@ -127,7 +127,8 @@ extern "C" {
* Integer value representing the log level for this entry. The higher the
* level, the more detail. Must be non-NULL.
* "logComponent"
- * Address of String representing the log component for this entry.
+ * PKIXERRORNUM value (defined in pkixt.h) designating the log component
+ * for this entry.
* "plContext"
* Platform-specific context pointer.
* THREAD SAFETY:
@@ -145,7 +146,7 @@ typedef PKIX_Error *
PKIX_Logger *logger,
PKIX_PL_String *message,
PKIX_UInt32 logLevel,
- PKIX_PL_String *logComponent,
+ PKIX_ERRORNUM logComponent,
void *plContext);
/*
@@ -310,7 +311,7 @@ PKIX_Logger_SetMaxLoggingLevel(
* Address of Logger whose logging component is to be stored.
* Must be non-NULL.
* "pComponent"
- * Address where object pointer will be stored. Must be non-NULL.
+ * Address where PKIXERRORNUM will be stored. Must be non-NULL.
* "plContext"
* Platform-specific context pointer.
* THREAD SAFETY:
@@ -324,7 +325,7 @@ PKIX_Logger_SetMaxLoggingLevel(
PKIX_Error *
PKIX_Logger_GetLoggingComponent(
PKIX_Logger *logger,
- PKIX_PL_String **pComponent,
+ PKIX_ERRORNUM *pComponent,
void *plContext);
/*
@@ -332,16 +333,15 @@ PKIX_Logger_GetLoggingComponent(
* DESCRIPTION:
*
* Sets the logging component of the Logger pointed to by "logger" with the
- * String pointed to by "component". A NULL component matches all components.
- * To match a small set of components, create a Logger for each.
+ * PKIXERRORNUM pointed to by "component". To match a small set of components,
+ * create a Logger for each.
*
* PARAMETERS:
* "logger"
* Address of Logger whose logging component is to be set.
* Must be non-NULL.
* "component"
- * Address of String representing logging component to be set.
- * If NULL, applies to all components.
+ * PKIXERRORNUM value representing logging component to be set.
* "plContext"
* Platform-specific context pointer.
* THREAD SAFETY:
@@ -355,10 +355,9 @@ PKIX_Logger_GetLoggingComponent(
PKIX_Error *
PKIX_Logger_SetLoggingComponent(
PKIX_Logger *logger,
- PKIX_PL_String *component,
+ PKIX_ERRORNUM component,
void *plContext);
-
/*
* FUNCTION: PKIX_GetLoggers
* DESCRIPTION:
diff --git a/security/nss/lib/libpkix/include/pkixt.h b/security/nss/lib/libpkix/include/pkixt.h
index 0023f540b..9cdf17d39 100755
--- a/security/nss/lib/libpkix/include/pkixt.h
+++ b/security/nss/lib/libpkix/include/pkixt.h
@@ -346,10 +346,10 @@ typedef int PKIX_Boolean;
#define ERRMACRO(type) PKIX_ ## type ## _ERROR
-enum {
+typedef enum {
PKIX_ERRORS,
PKIX_NUMERRORS /* This gets PKIX_NUMERRORS defined as the total number */
-};
+} PKIX_ERRORNUM;
/* String Formats
*
diff --git a/security/nss/lib/libpkix/pkix/util/pkix_logger.c b/security/nss/lib/libpkix/pkix/util/pkix_logger.c
index bed24fc07..006fd1682 100644
--- a/security/nss/lib/libpkix/pkix/util/pkix_logger.c
+++ b/security/nss/lib/libpkix/pkix/util/pkix_logger.c
@@ -119,7 +119,7 @@ pkix_Logger_Check(
PKIX_List *pkixLoggersList,
char *message,
char *message2,
- PKIX_UInt32 logComponent,
+ PKIX_ERRORNUM logComponent,
PKIX_UInt32 currentLevel,
void *plContext)
{
@@ -130,7 +130,6 @@ pkix_Logger_Check(
PKIX_PL_String *messageString = NULL;
PKIX_PL_String *message2String = NULL;
PKIX_PL_String *msgString = NULL;
- PKIX_PL_String *logComponentString = NULL;
PKIX_Error *error = NULL;
PKIX_Boolean needLogging = PKIX_FALSE;
PKIX_UInt32 i, length;
@@ -194,22 +193,6 @@ pkix_Logger_Check(
message2String);
if (error) { goto cleanup; }
- /*
- * Convert component to String : see pkixt.h for reason that we have to
- * use PKIX_NUMERRORS.
- */
- if (logComponent >= PKIX_NUMERRORS) {
- goto cleanup;
- }
-
- error = PKIX_PL_String_Create
- (PKIX_ESCASCII,
- (void *)PKIX_ERRORNAMES[logComponent],
- 0,
- &logComponentString,
- plContext);
- if (error) { goto cleanup; }
-
/* Go through the Logger list */
error = PKIX_List_GetLength(pkixLoggersList, &length, plContext);
@@ -227,7 +210,7 @@ pkix_Logger_Check(
/* Intended logging level less or equal than the max */
needLogging = (currentLevel <= logger->maxLevel);
- if (needLogging && logger->callback) {
+ if (needLogging && (logger->callback)) {
/*
* We separate Logger into two lists based on log level
@@ -238,17 +221,16 @@ pkix_Logger_Check(
needLogging = needLogging &&
(currentLevel <= PKIX_LOGGER_LEVEL_WARNING);
} else if (pkixLoggersList == pkixLoggersDebugTrace) {
- needLogging = needLogging &&
+ needLogging = needLogging &&
(currentLevel > PKIX_LOGGER_LEVEL_WARNING);
}
- if (needLogging && logger->logComponent) {
- error = PKIX_PL_Object_Equals(
- (PKIX_PL_Object *) logComponentString,
- (PKIX_PL_Object *) logger->logComponent,
- &needLogging,
- plContext);
- if (error) { goto cleanup; }
+ if (needLogging) {
+ if (logComponent == logger->logComponent) {
+ needLogging = PKIX_TRUE;
+ } else {
+ needLogging = PKIX_FALSE;
+ }
}
if (needLogging) {
@@ -256,11 +238,10 @@ pkix_Logger_Check(
(logger,
msgString,
currentLevel,
- logComponentString,
+ logComponent,
plContext);
if (error) { goto cleanup; }
}
-
}
error = PKIX_PL_Object_DecRef
@@ -292,11 +273,6 @@ cleanup:
((PKIX_PL_Object *)msgString, plContext);
}
- if (logComponentString) {
- error = PKIX_PL_Object_DecRef
- ((PKIX_PL_Object *)logComponentString, plContext);
- }
-
if (logger) {
error = PKIX_PL_Object_DecRef
((PKIX_PL_Object *)logger, plContext);
@@ -341,7 +317,7 @@ pkix_Logger_Destroy(
logger->callback = NULL;
PKIX_DECREF(logger->context);
- PKIX_DECREF(logger->logComponent);
+ logger->logComponent = (PKIX_ERRORNUM)NULL;
cleanup:
@@ -362,6 +338,7 @@ pkix_Logger_ToString(
char *asciiFormat = NULL;
PKIX_PL_String *formatString = NULL;
PKIX_PL_String *contextString = NULL;
+ PKIX_PL_String *componentString = NULL;
PKIX_PL_String *loggerString = NULL;
PKIX_ENTER(LOGGER, "pkix_Logger_ToString_Helper");
@@ -378,7 +355,7 @@ pkix_Logger_ToString(
"\tLogger: \n"
"\tContext: %s\n"
"\tMaximum Level: %d\n"
- "\tComponment Name: %s\n"
+ "\tComponent Name: %s\n"
"]\n";
PKIX_CHECK(PKIX_PL_String_Create
@@ -392,13 +369,21 @@ pkix_Logger_ToString(
PKIX_TOSTRING(logger->context, &contextString, plContext,
"PKIX_PL_Object_ToString failed");
+ PKIX_CHECK(PKIX_PL_String_Create
+ (PKIX_ESCASCII,
+ (void *)PKIX_ERRORNAMES[logger->logComponent],
+ 0,
+ &componentString,
+ plContext),
+ "PKIX_PL_String_Create failed");
+
PKIX_CHECK(PKIX_PL_Sprintf
(&loggerString,
plContext,
formatString,
contextString,
logger->maxLevel,
- logger->logComponent),
+ componentString),
"PKIX_PL_Sprintf failed");
*pString = loggerString;
@@ -461,6 +446,10 @@ pkix_Logger_Equals(
goto cleanup;
}
+ if (firstLogger->logComponent != secondLogger->logComponent) {
+ goto cleanup;
+ }
+
PKIX_EQUALS
(firstLogger->context,
secondLogger->context,
@@ -476,13 +465,6 @@ pkix_Logger_Equals(
goto cleanup;
}
- PKIX_EQUALS
- ((PKIX_PL_Object *)firstLogger->logComponent,
- (PKIX_PL_Object *)secondLogger->logComponent,
- &cmpResult,
- plContext,
- "PKIX_PL_Object_Equals failed");
-
*pResult = cmpResult;
cleanup:
@@ -515,13 +497,8 @@ pkix_Logger_Hashcode(
PKIX_HASHCODE(logger->context, &tempHash, plContext,
"PKIX_PL_Object_Hashcode failed");
- hash = (PKIX_UInt32) logger->callback + tempHash << 7 +
- logger->maxLevel;
-
- PKIX_HASHCODE(logger->logComponent, &tempHash, plContext,
- "PKIX_PL_Object_Hashcode failed");
-
- hash = hash << 7 + tempHash;
+ hash = ((((PKIX_UInt32) logger->callback + tempHash) << 7) +
+ logger->maxLevel << 7) + (PKIX_UInt32)logger->logComponent;
*pHashcode = hash;
@@ -569,11 +546,7 @@ pkix_Logger_Duplicate(
plContext,
"PKIX_PL_Object_Duplicate failed");
- PKIX_DUPLICATE
- (logger->logComponent,
- &dupLogger->logComponent,
- plContext,
- "PKIX_PL_Object_Duplicate failed");
+ dupLogger->logComponent = logger->logComponent;
*pNewObject = (PKIX_PL_Object *) dupLogger;
@@ -644,7 +617,7 @@ PKIX_Logger_Create(
logger->callback = callback;
logger->maxLevel = 0;
- logger->logComponent = NULL;
+ logger->logComponent = (PKIX_ERRORNUM)NULL;
PKIX_INCREF(loggerContext);
logger->context = loggerContext;
@@ -737,13 +710,12 @@ cleanup:
PKIX_Error *
PKIX_Logger_GetLoggingComponent(
PKIX_Logger *logger,
- PKIX_PL_String **pComponent,
+ PKIX_ERRORNUM *pComponent,
void *plContext)
{
PKIX_ENTER(LOGGER, "PKIX_Logger_GetLoggingComponent");
PKIX_NULLCHECK_TWO(logger, pComponent);
- PKIX_INCREF(logger->logComponent);
*pComponent = logger->logComponent;
PKIX_RETURN(LOGGER);
@@ -755,14 +727,12 @@ PKIX_Logger_GetLoggingComponent(
PKIX_Error *
PKIX_Logger_SetLoggingComponent(
PKIX_Logger *logger,
- PKIX_PL_String *component,
+ PKIX_ERRORNUM component,
void *plContext)
{
PKIX_ENTER(LOGGER, "PKIX_Logger_SetLoggingComponent");
PKIX_NULLCHECK_ONE(logger);
- PKIX_DECREF(logger->logComponent);
- PKIX_INCREF(component);
logger->logComponent = component;
PKIX_RETURN(LOGGER);
@@ -891,7 +861,7 @@ PKIX_SetLoggers(
"PKIX_PL_MonitorLock_Enter failed");
locked = PKIX_TRUE;
- /* Disable tracing, etc. to avoid recursion and deadlock */
+ /* Disable tracing, etc. to avoid recursion and deadlock */
savedPkixLoggersDebugTrace = pkixLoggersDebugTrace;
pkixLoggersDebugTrace = NULL;
savedPkixLoggersErrors = pkixLoggersErrors;
diff --git a/security/nss/lib/libpkix/pkix/util/pkix_logger.h b/security/nss/lib/libpkix/pkix/util/pkix_logger.h
index 1996b1947..890f4611d 100644
--- a/security/nss/lib/libpkix/pkix/util/pkix_logger.h
+++ b/security/nss/lib/libpkix/pkix/util/pkix_logger.h
@@ -58,7 +58,7 @@ struct PKIX_LoggerStruct {
PKIX_Logger_LogCallback callback;
PKIX_PL_Object *context;
PKIX_UInt32 maxLevel;
- PKIX_PL_String *logComponent;
+ PKIX_ERRORNUM logComponent;
};
PKIX_Error *
@@ -66,7 +66,7 @@ pkix_Logger_Check(
PKIX_List *pkixLoggersList,
char *message,
char *message2,
- PKIX_UInt32 logComponent,
+ PKIX_ERRORNUM logComponent,
PKIX_UInt32 maxLevel,
void *plContext);