[mapserver-commits] r7393 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Mon Feb 18 17:17:01 EST 2008


Author: tomkralidis
Date: 2008-02-18 17:17:01 -0500 (Mon, 18 Feb 2008)
New Revision: 7393

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapogcsos.c
Log:
- handle invalid XML POST requests (#2521)


Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2008-02-18 17:03:02 UTC (rev 7392)
+++ trunk/mapserver/HISTORY.TXT	2008-02-18 22:17:01 UTC (rev 7393)
@@ -13,6 +13,8 @@
 Current Version (5.1-dev, SVN trunk):
 -------------------------------------
 
+- mapogcsos.c: handle invalid POST requests (#2521)
+
 - mapogcsos.c: handle ACCEPTVERSIONS parameter (#2515)
 
 - mapwcs.c/mapwcs11.c: s/neighbour/neighbor/g (#2518)

Modified: trunk/mapserver/mapogcsos.c
===================================================================
--- trunk/mapserver/mapogcsos.c	2008-02-18 17:03:02 UTC (rev 7392)
+++ trunk/mapserver/mapogcsos.c	2008-02-18 22:17:01 UTC (rev 7393)
@@ -62,7 +62,7 @@
   xmlNodePtr psResultNode;
 } SOSProcedureNode;
 
-void msSOSParseRequest(cgiRequestObj *request, sosParamsObj *sosparams);
+int msSOSParseRequest(mapObj *map, cgiRequestObj *request, sosParamsObj *sosparams);
 void msSOSFreeParamsObj(sosParamsObj *sosparams);
 
 /*
@@ -2530,7 +2530,8 @@
   int returnvalue = MS_DONE;
   sosParamsObj *paramsObj = (sosParamsObj *)calloc(1, sizeof(sosParamsObj));
 
-  msSOSParseRequest(req, paramsObj);
+  if (msSOSParseRequest(map, req, paramsObj) == MS_FAILURE)
+    return MS_FAILURE;
 
   /* SERVICE must be specified and be SOS */
   if (paramsObj->pszService && strcasecmp(paramsObj->pszService, "SOS") == 0) { /* this is an SOS request */
@@ -2597,7 +2598,7 @@
 
 #if defined(USE_SOS_SVR) && defined(USE_LIBXML2)
 
-void msSOSParseRequest(cgiRequestObj *request, sosParamsObj *sosparams) {
+int msSOSParseRequest(mapObj *map, cgiRequestObj *request, sosParamsObj *sosparams) {
   int i;
   xmlDocPtr doc;
   xmlXPathContextPtr context;
@@ -2649,18 +2650,21 @@
     /* load document */
     doc = xmlParseDoc((xmlChar *)request->postrequest);
     if (doc == NULL ) {
-      return;
+      msSetError(MS_SOSERR, "Invalid POST request.  XML is not well-formed", "msSOSParseRequest()");
+      return msSOSException(map, "request", "NoApplicableCode");
     }
 
     /* load context */
     context = xmlXPathNewContext(doc);
     if (context == NULL) {
-      return;
+      msSetError(MS_SOSERR, "Could not create context (xmlXPathNewContext)", "msSOSParseRequest()");
+      return msSOSException(map, "request", "NoApplicableCode");
     }
 
     /* register namespaces */
     if(xmlXPathRegisterNs(context, (xmlChar *)"sos", (xmlChar *)"http://www.opengis.net/sos/1.0") != 0 || xmlXPathRegisterNs(context, (xmlChar *)"ows", (xmlChar *)"http://www.opengis.net/ows/1.1") != 0) {
-      return;
+      msSetError(MS_SOSERR, "Could not register namespaces (xmlXPathRegisterNs)", "msSOSParseRequest()");
+      return msSOSException(map, "request", "NoApplicableCode");
     }
 
     /* check for service */
@@ -2795,7 +2799,7 @@
     xmlFreeDoc(doc);
     xmlCleanupParser();
   }
-  return;
+  return MS_SUCCESS;
 }
 
 void msSOSFreeParamsObj(sosParamsObj *sosparams) {



More information about the mapserver-commits mailing list