summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcc1.yim <cc1.yim@samsung.com>2013-06-26 18:13:42 +0900
committercc1.yim <cc1.yim@samsung.com>2013-06-26 18:13:51 +0900
commit1d266231f3e11b7f6ef628c9880d81196f8efa44 (patch)
tree316f9b84562432133cb6411963925f4b118bdd01
parent09ec196e6dd5f3564d573406cf5d721ef11cf942 (diff)
downloadxmlsec1-submit/tizen_2.2/20130714.155028.tar.gz
xmlsec1-submit/tizen_2.2/20130714.155028.tar.bz2
xmlsec1-submit/tizen_2.2/20130714.155028.zip
Change-Id: I6a90e62201db9828da63c0b271fa874b2ad05289 Signed-off-by: cc1.yim <cc1.yim@samsung.com>
-rw-r--r--src/errors.c50
-rw-r--r--src/io.c6
-rw-r--r--src/openssl/digests.c4
-rw-r--r--src/xmldsig.c15
4 files changed, 48 insertions, 27 deletions
diff --git a/src/errors.c b/src/errors.c
index 54e34e6c..128307f2 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,
@@ -219,24 +220,39 @@ xmlSecErrorsGetMsg(xmlSecSize pos) {
* application specific callback installed using #xmlSecErrorsSetCallback
* function.
*/
-void
+void
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];
-
- if(msg != NULL) {
- va_list va;
-
- va_start(va, msg);
- xmlSecStrVPrintf(error_msg, sizeof(error_msg), 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);
- }
+ 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 + 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); }
}
diff --git a/src/io.c b/src/io.c
index a691f68b..c3e8821a 100644
--- a/src/io.c
+++ b/src/io.c
@@ -424,9 +424,9 @@ xmlSecTransformInputURIOpen(xmlSecTransformPtr transform, const xmlChar *uri) {
xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
"opencallback",
XMLSEC_ERRORS_R_IO_FAILED,
- "uri=%s;errno=%d",
+ "uri=%s;error=%s",
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);
+ "error=%s", strerror(errno));
return(-1);
}
(*dataSize) = ret;
diff --git a/src/openssl/digests.c b/src/openssl/digests.c
index c681e857..31813ed6 100644
--- a/src/openssl/digests.c
+++ b/src/openssl/digests.c
@@ -222,7 +222,7 @@ xmlSecOpenSSLEvpDigestVerify(xmlSecTransformPtr transform,
"data_size=%d;dgst_size=%d",
dataSize, ctx->dgstSize);
transform->status = xmlSecTransformStatusFail;
- return(0);
+ return -1;//(0);
}
if(memcmp(ctx->dgst, data, ctx->dgstSize) != 0) {
@@ -232,7 +232,7 @@ xmlSecOpenSSLEvpDigestVerify(xmlSecTransformPtr transform,
XMLSEC_ERRORS_R_INVALID_DATA,
"data and digest do not match");
transform->status = xmlSecTransformStatusFail;
- return(0);
+ return -1;//(0);
}
transform->status = xmlSecTransformStatusOk;
diff --git a/src/xmldsig.c b/src/xmldsig.c
index cbd825e5..88ba24e5 100644
--- a/src/xmldsig.c
+++ b/src/xmldsig.c
@@ -49,6 +49,7 @@ static int xmlSecDSigCtxProcessManifestNode (xmlSecDSigCtxPtr dsigCtx,
/* The ID attribute in XMLDSig is 'Id' */
static const xmlChar* xmlSecDSigIds[] = { xmlSecAttrId, NULL };
+static char logMsg[1024];
/**
* xmlSecDSigCtxCreate:
@@ -1568,16 +1569,18 @@ 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);
+ XMLSEC_ERRORS_R_XMLSEC_FAILED,
+ logMsg);
return(-1);
}
dsigRefCtx->result = transformCtx->result;
- if(dsigRefCtx->dsigCtx->operation == xmlSecTransformOperationSign) {
+ if(dsigRefCtx->dsigCtx->operation == xmlSecTransformOperationSign) {
if((dsigRefCtx->result == NULL) || (xmlSecBufferGetData(dsigRefCtx->result) == NULL)) {
xmlSecError(XMLSEC_ERRORS_HERE,
NULL,
@@ -1599,11 +1602,13 @@ xmlSecDSigReferenceCtxProcessNode(xmlSecDSigReferenceCtxPtr dsigRefCtx, xmlNodeP
ret = xmlSecTransformVerifyNodeContent(dsigRefCtx->digestMethod,
digestValueNode, transformCtx);
if(ret < 0) {
- xmlSecError(XMLSEC_ERRORS_HERE,
+ 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);
+ logMsg);
return(-1);
}