summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2004-11-28 20:29:41 +0000
committerFrederic Peters <fpeters@entrouvert.com>2004-11-28 20:29:41 +0000
commit6a59e6f8211449fd0fc4bce2f2ea2858fced4e70 (patch)
tree391237bfc1e08d9ce86fab2c138425382bfd04f0
parent3702e3dacb1dbe5d191fc9537b7af1346ba24970 (diff)
downloadlasso-6a59e6f8211449fd0fc4bce2f2ea2858fced4e70.tar.gz
lasso-6a59e6f8211449fd0fc4bce2f2ea2858fced4e70.tar.xz
lasso-6a59e6f8211449fd0fc4bce2f2ea2858fced4e70.zip
error checking in lasso_profile_get_request_type_from_soap_msg()
-rw-r--r--lasso/id-ff/profile.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/lasso/id-ff/profile.c b/lasso/id-ff/profile.c
index 4005dfd7..9c726e54 100644
--- a/lasso/id-ff/profile.c
+++ b/lasso/id-ff/profile.c
@@ -83,38 +83,32 @@ lasso_profile_get_request_type_from_soap_msg(const gchar *soap)
xmlDoc *doc;
xmlXPathContext *xpathCtx;
xmlXPathObject *xpathObj;
- const xmlChar *name;
-
lassoRequestType type = LASSO_REQUEST_TYPE_INVALID;
-
- /* FIXME: totally lacking error checking */
+ const char *name = NULL;
doc = xmlParseMemory(soap, strlen(soap));
xpathCtx = xmlXPathNewContext(doc);
xmlXPathRegisterNs(xpathCtx, "s", LASSO_SOAP_ENV_HREF);
xpathObj = xmlXPathEvalExpression("//s:Body/*", xpathCtx);
- name = xpathObj->nodesetval->nodeTab[0]->name;
+ if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr)
+ name = xpathObj->nodesetval->nodeTab[0]->name;
- if (xmlStrEqual(name, "Request")) {
+ if (name == NULL) {
+ message(G_LOG_LEVEL_WARNING, "Invalid SOAP request");
+ } else if (strcmp(name, "Request") == 0) {
type = LASSO_REQUEST_TYPE_LOGIN;
- }
- else if (xmlStrEqual(name, "LogoutRequest")) {
+ } else if (strcmp(name, "LogoutRequest") == 0) {
type = LASSO_REQUEST_TYPE_LOGOUT;
- }
- else if (xmlStrEqual(name, "FederationTerminationNotification")) {
+ } else if (strcmp(name, "FederationTerminationNotification") == 0) {
type = LASSO_REQUEST_TYPE_DEFEDERATION;
- }
- else if (xmlStrEqual(name, "RegisterNameIdentifierRequest")) {
+ } else if (strcmp(name, "RegisterNameIdentifierRequest") == 0) {
type = LASSO_REQUEST_TYPE_NAME_REGISTRATION;
- }
- else if (xmlStrEqual(name, "NameIdentifierMappingRequest")) {
+ } else if (strcmp(name, "NameIdentifierMappingRequest") == 0) {
type = LASSO_REQUEST_TYPE_NAME_IDENTIFIER_MAPPING;
- }
- else if (xmlStrEqual(name, "AuthnRequest")) {
+ } else if (strcmp(name, "AuthnRequest") == 0) {
type = LASSO_REQUEST_TYPE_LECP;
- }
- else {
+ } else {
message(G_LOG_LEVEL_WARNING, "Unkown node name : %s", name);
}