summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorAleksey Sanin <aleksey@src.gnome.org>2003-03-19 19:19:01 +0000
committerAleksey Sanin <aleksey@src.gnome.org>2003-03-19 19:19:01 +0000
commited207b6fc67b3a2eb6bfc7977aef295cb0680c81 (patch)
tree83f234a4d3b6e4d4113e96dbee1f756b41deeaaf /apps
parent1e05ec0d1592e25ce0582485f52b8266f2d01a3e (diff)
downloadxmlsec1-ed207b6fc67b3a2eb6bfc7977aef295cb0680c81.tar.gz
xmlsec1-ed207b6fc67b3a2eb6bfc7977aef295cb0680c81.tar.bz2
xmlsec1-ed207b6fc67b3a2eb6bfc7977aef295cb0680c81.zip
force Signature/EncryptedData node selection when using --node-xpath, --node-name and --node-id options for xmlsec comnad line tool
Diffstat (limited to 'apps')
-rw-r--r--apps/xmlsec.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/apps/xmlsec.c b/apps/xmlsec.c
index 11b3a313..d8599c15 100644
--- a/apps/xmlsec.c
+++ b/apps/xmlsec.c
@@ -647,7 +647,7 @@ struct _xmlSecAppXmlData {
static xmlSecAppXmlDataPtr xmlSecAppXmlDataCreate (const char* filename,
const xmlChar* defStartNodeName,
const xmlChar* defStartNodeNs);
-static void xmlSecAppXmlDataDestroy (xmlSecAppXmlDataPtr data);
+static void xmlSecAppXmlDataDestroy (xmlSecAppXmlDataPtr data);
static xmlSecAppCommand xmlSecAppParseCommand (const char* cmd,
@@ -1591,7 +1591,8 @@ xmlSecAppShutdown(void) {
static xmlSecAppXmlDataPtr
xmlSecAppXmlDataCreate(const char* filename, const xmlChar* defStartNodeName, const xmlChar* defStartNodeNs) {
xmlSecAppXmlDataPtr data;
-
+ xmlNodePtr cur = NULL;
+
if(filename == NULL) {
fprintf(stderr, "Error: xml filename is null\n");
return(NULL);
@@ -1642,7 +1643,7 @@ xmlSecAppXmlDataCreate(const char* filename, const xmlChar* defStartNodeName, co
xmlSecAppXmlDataDestroy(data);
return(NULL);
}
- data->startNode = attr->parent;
+ cur = attr->parent;
} else if(xmlSecAppCmdLineParamGetString(&nodeNameParam) != NULL) {
xmlChar* buf;
xmlChar* name;
@@ -1664,8 +1665,8 @@ xmlSecAppXmlDataCreate(const char* filename, const xmlChar* defStartNodeName, co
ns = NULL;
}
- data->startNode = xmlSecFindNode(xmlDocGetRootElement(data->doc), name, ns);
- if(data->startNode == NULL) {
+ cur = xmlSecFindNode(xmlDocGetRootElement(data->doc), name, ns);
+ if(cur == NULL) {
fprintf(stderr, "Error: failed to find node with name=\"%s\"\n",
name);
xmlFree(buf);
@@ -1700,25 +1701,29 @@ xmlSecAppXmlDataCreate(const char* filename, const xmlChar* defStartNodeName, co
return(NULL);
}
- data->startNode = obj->nodesetval->nodeTab[0];
+ cur = obj->nodesetval->nodeTab[0];
xmlXPathFreeContext(ctx);
xmlXPathFreeObject(obj);
- } else if(defStartNodeName != NULL) {
- data->startNode = xmlSecFindNode(xmlDocGetRootElement(data->doc), defStartNodeName, defStartNodeNs);
- if(data->startNode == NULL) {
- fprintf(stderr, "Error: failed to find default node with name=\"%s\"\n",
- defStartNodeName);
+ } else {
+ cur = xmlDocGetRootElement(data->doc);
+ if(cur == NULL) {
+ fprintf(stderr, "Error: failed to get root element\n");
xmlSecAppXmlDataDestroy(data);
return(NULL);
}
- } else {
- data->startNode = xmlDocGetRootElement(data->doc);
+ }
+
+ if(defStartNodeName != NULL) {
+ data->startNode = xmlSecFindNode(cur, defStartNodeName, defStartNodeNs);
if(data->startNode == NULL) {
- fprintf(stderr, "Error: failed to get root element\n");
+ fprintf(stderr, "Error: failed to find default node with name=\"%s\"\n",
+ defStartNodeName);
xmlSecAppXmlDataDestroy(data);
return(NULL);
}
+ } else {
+ data->startNode = cur;
}
return(data);