summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcc1.yim <cc1.yim@samsung.com>2013-06-26 18:13:42 +0900
committerAnas Nashif <anas.nashif@intel.com>2013-09-23 04:26:54 -0400
commit54bb2f3d916df410e0576638822b7693d8b4cf9a (patch)
tree9e69fec989dc08ade49b06a06d1d1c4f739321ee
parent07d62412cf2891883d1a7d79e6f50e282793dd49 (diff)
downloadxmlsec1-54bb2f3d916df410e0576638822b7693d8b4cf9a.tar.gz
xmlsec1-54bb2f3d916df410e0576638822b7693d8b4cf9a.tar.bz2
xmlsec1-54bb2f3d916df410e0576638822b7693d8b4cf9a.zip
modify error log
Change-Id: I6a90e62201db9828da63c0b271fa874b2ad05289 Signed-off-by: cc1.yim <cc1.yim@samsung.com> Signed-off-by: Anas Nashif <anas.nashif@intel.com>
-rw-r--r--src/errors.c34
-rw-r--r--src/io.c4
-rw-r--r--src/openssl/digests.c4
-rw-r--r--src/xmldsig.c39
4 files changed, 51 insertions, 30 deletions
diff --git a/src/errors.c b/src/errors.c
index c9886d36..c01a4925 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -114,6 +114,7 @@ xmlSecErrorsShutdown(void) {
void
xmlSecErrorsSetCallback(xmlSecErrorsCallback callback) {
xmlSecErrorsClbk = callback;
+ xmlSecErrorsDefaultCallbackEnableOutput(0);
}
/**
@@ -144,7 +145,7 @@ xmlSecErrorsDefaultCallback(const char* file, int line, const char* func,
}
}
xmlGenericError(xmlGenericErrorContext,
- "func=%s:file=%s:line=%d:obj=%s:subj=%s:error=%d:%s:%s\n",
+ "func=%s:file=%s:line=%d:obj=%s:subj=%s:error=%d:<%s>:<%s>\n",
(func != NULL) ? func : "unknown",
(file != NULL) ? file : "unknown",
line,
@@ -220,23 +221,38 @@ xmlSecErrorsGetMsg(xmlSecSize pos) {
* function.
*/
void
-xmlSecError(const char* file, int line, const char* func,
- const char* errorObject, const char* errorSubject,
- int reason, const char* msg, ...) {
+xmlSecError(const char* file, int line, const char* func,
+ const char* errorObject, const char* errorSubject,
+ int reason, const char* msg, ...) {
if(xmlSecErrorsClbk != NULL) {
- xmlChar error_msg[XMLSEC_ERRORS_BUFFER_SIZE];
+ xmlChar error_msg[XMLSEC_ERRORS_BUFFER_SIZE] = {'\0',};
+ const char* e_msg = NULL;
+ xmlSecSize i;
+ int len = 0;
+
+ if(xmlSecPrintErrorMessages == 0) {
+ if(reason != XMLSEC_ERRORS_MAX_NUMBER) {
+ for(i = 0; (i < XMLSEC_ERRORS_MAX_NUMBER) && (xmlSecErrorsGetMsg(i) != NULL); ++i) {
+ if(xmlSecErrorsGetCode(i) == reason) {
+ e_msg = xmlSecErrorsGetMsg(i);
+ sprintf(error_msg , "%s] [", e_msg);
+ len = strlen(error_msg);
+ break;
+ }
+ }
+ }
+ }
if(msg != NULL) {
va_list va;
-
va_start(va, msg);
- xmlSecStrVPrintf(error_msg, sizeof(error_msg), BAD_CAST msg, va);
+ xmlSecStrVPrintf(error_msg + len, sizeof(error_msg) - len, BAD_CAST msg, va);
error_msg[sizeof(error_msg) - 1] = '\0';
va_end(va);
} else {
error_msg[0] = '\0';
}
- xmlSecErrorsClbk(file, line, func, errorObject, errorSubject, reason, (char*)error_msg);
- }
+
+ xmlSecErrorsClbk(file, line, func, errorObject, errorSubject, reason, (char*)error_msg); }
}
diff --git a/src/io.c b/src/io.c
index 42e91337..77344c08 100644
--- a/src/io.c
+++ b/src/io.c
@@ -426,7 +426,7 @@ xmlSecTransformInputURIOpen(xmlSecTransformPtr transform, const xmlChar *uri) {
XMLSEC_ERRORS_R_IO_FAILED,
"uri=%s;errno=%d",
xmlSecErrorsSafeString(uri),
- errno);
+ strerror(errno));
return(-1);
}
@@ -484,7 +484,7 @@ xmlSecTransformInputURIPopBin(xmlSecTransformPtr transform, xmlSecByte* data,
xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
"readcallback",
XMLSEC_ERRORS_R_IO_FAILED,
- "errno=%d", errno);
+ "errno=%d", strerror(errno));
return(-1);
}
(*dataSize) = ret;
diff --git a/src/openssl/digests.c b/src/openssl/digests.c
index fa26fa65..0e0978f7 100644
--- a/src/openssl/digests.c
+++ b/src/openssl/digests.c
@@ -243,7 +243,7 @@ xmlSecOpenSSLEvpDigestVerify(xmlSecTransformPtr transform,
"data_size=%d;dgst_size=%d",
dataSize, ctx->dgstSize);
transform->status = xmlSecTransformStatusFail;
- return(0);
+ return -1;
}
if(memcmp(ctx->dgst, data, ctx->dgstSize) != 0) {
@@ -253,7 +253,7 @@ xmlSecOpenSSLEvpDigestVerify(xmlSecTransformPtr transform,
XMLSEC_ERRORS_R_INVALID_DATA,
"data and digest do not match");
transform->status = xmlSecTransformStatusFail;
- return(0);
+ return -1;
}
transform->status = xmlSecTransformStatusOk;
diff --git a/src/xmldsig.c b/src/xmldsig.c
index b08b8b11..800aa25b 100644
--- a/src/xmldsig.c
+++ b/src/xmldsig.c
@@ -49,6 +49,7 @@ static int xmlSecDSigCtxProcessManifestNode (xmlSecDSigCtxPtr dsigCt
/* The ID attribute in XMLDSig is 'Id' */
static const xmlChar* xmlSecDSigIds[] = { xmlSecAttrId, NULL };
+static char logMsg[1024];
/**
* xmlSecDSigCtxCreate:
@@ -1568,42 +1569,46 @@ xmlSecDSigReferenceCtxProcessNode(xmlSecDSigReferenceCtxPtr dsigRefCtx, xmlNodeP
/* finally get transforms results */
ret = xmlSecTransformCtxExecute(transformCtx, node->doc);
if(ret < 0) {
+ sprintf(logMsg, "uri:%s", (char*)dsigRefCtx->uri);
+ logMsg[strlen(dsigRefCtx->uri)+5] = '\0';
xmlSecError(XMLSEC_ERRORS_HERE,
- NULL,
- "xmlSecTransformCtxExecute",
- XMLSEC_ERRORS_R_XMLSEC_FAILED,
- XMLSEC_ERRORS_NO_MESSAGE);
+ NULL,
+ "xmlSecTransformCtxExecute",
+ XMLSEC_ERRORS_R_XMLSEC_FAILED,
+ logMsg);
return(-1);
- }
+ }
dsigRefCtx->result = transformCtx->result;
if(dsigRefCtx->dsigCtx->operation == xmlSecTransformOperationSign) {
if((dsigRefCtx->result == NULL) || (xmlSecBufferGetData(dsigRefCtx->result) == NULL)) {
xmlSecError(XMLSEC_ERRORS_HERE,
- NULL,
- "xmlSecTransformCtxExecute",
- XMLSEC_ERRORS_R_XMLSEC_FAILED,
- XMLSEC_ERRORS_NO_MESSAGE);
+ NULL,
+ "xmlSecTransformCtxExecute",
+ XMLSEC_ERRORS_R_XMLSEC_FAILED,
+ XMLSEC_ERRORS_NO_MESSAGE);
return(-1);
}
/* write signed data to xml */
xmlNodeSetContentLen(digestValueNode,
- xmlSecBufferGetData(dsigRefCtx->result),
- xmlSecBufferGetSize(dsigRefCtx->result));
+ xmlSecBufferGetData(dsigRefCtx->result),
+ xmlSecBufferGetSize(dsigRefCtx->result));
/* set success status and we are done */
dsigRefCtx->status = xmlSecDSigStatusSucceeded;
} else {
/* verify SignatureValue node content */
- ret = xmlSecTransformVerifyNodeContent(dsigRefCtx->digestMethod,
- digestValueNode, transformCtx);
+ ret = xmlSecTransformVerifyNodeContent(dsigRefCtx->digestMethod,
+ digestValueNode, transformCtx);
if(ret < 0) {
+ sprintf(logMsg, "uri:%s", (char*)dsigRefCtx->uri);
+ logMsg[strlen(dsigRefCtx->uri)+5] = '\0';
xmlSecError(XMLSEC_ERRORS_HERE,
- NULL,
- "xmlSecTransformVerifyNodeContent",
- XMLSEC_ERRORS_R_XMLSEC_FAILED,
- XMLSEC_ERRORS_NO_MESSAGE);
+ NULL,
+ "xmlSecTransformVerifyNodeContent",
+ XMLSEC_ERRORS_R_XMLSEC_FAILED,
+ logMsg);
return(-1);
}