From 6600f475495e3d5cd8819fae3490150e8a66404f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 26 Jun 2015 11:34:35 +0200 Subject: [PATCH 1/2] Prevent XML external entities from being fetched with libxml2 < 2.9.0 --- mapows.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mapows.c b/mapows.c index 0785aacb8c..d07e689b0f 100644 --- a/mapows.c +++ b/mapows.c @@ -79,6 +79,17 @@ static void msOWSClearRequestObj(owsRequestObj *ows_request) } } +#if defined(USE_LIBXML2) && LIBXML_VERSION < 20900 +static int bExternalEntityAsked = FALSE; +static xmlParserInputPtr dummyEntityLoader(const char * URL, + const char * ID, + xmlParserCtxtPtr context ) +{ + bExternalEntityAsked = TRUE; + return NULL; +} +#endif + /* ** msOWSPreParseRequest() parses a cgiRequestObj either with GET/KVP ** or with POST/XML. Only SERVICE, VERSION (or WMTVER) and REQUEST are @@ -117,6 +128,9 @@ static int msOWSPreParseRequest(cgiRequestObj *request, } else if (request->type == MS_POST_REQUEST) { #if defined(USE_LIBXML2) xmlNodePtr root = NULL; +#if LIBXML_VERSION < 20900 + xmlExternalEntityLoader oldExternalEntityLoader; +#endif #elif defined(USE_GDAL) CPLXMLNode *temp; #endif @@ -126,9 +140,24 @@ static int msOWSPreParseRequest(cgiRequestObj *request, return MS_FAILURE; } #if defined(USE_LIBXML2) +#if LIBXML_VERSION < 20900 + oldExternalEntityLoader = xmlGetExternalEntityLoader(); + /* to avoid XML External Entity vulnerability with libxml2 < 2.9 */ + xmlSetExternalEntityLoader (dummyEntityLoader); + bExternalEntityAsked = FALSE; +#endif /* parse to DOM-Structure with libxml2 and get the root element */ ows_request->document = xmlParseMemory(request->postrequest, strlen(request->postrequest)); +#if LIBXML_VERSION < 20900 + xmlSetExternalEntityLoader (oldExternalEntityLoader); + if( bExternalEntityAsked ) + { + msSetError(MS_OWSERR, "XML parsing error: %s", + "msOWSPreParseRequest()", "External entity fetch"); + return MS_FAILURE; + } +#endif if (ows_request->document == NULL || (root = xmlDocGetRootElement(ows_request->document)) == NULL) { xmlErrorPtr error = xmlGetLastError(); From 1882b7c0f5898c14661bcffe00665c3f365da1e2 Mon Sep 17 00:00:00 2001 From: Thomas Bonfort Date: Mon, 29 Jun 2015 08:34:25 +0200 Subject: [PATCH 2/2] update version number to 6.4.2 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f23910b67f..ba6c3a29fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ include(CheckCSourceCompiles) set (MapServer_VERSION_MAJOR 6) set (MapServer_VERSION_MINOR 4) -set (MapServer_VERSION_REVISION 1) +set (MapServer_VERSION_REVISION 2) set (MapServer_VERSION_SUFFIX "") set(TARGET_VERSION_MAJOR ${MapServer_VERSION_MAJOR})