[mapserver-commits] r10541 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Wed Sep 29 22:44:54 EDT 2010


Author: warmerdam
Date: 2010-09-30 02:44:54 +0000 (Thu, 30 Sep 2010)
New Revision: 10541

Modified:
   trunk/mapserver/mapwmslayer.c
Log:
handle xml errors in non-file case too (#3555)

Modified: trunk/mapserver/mapwmslayer.c
===================================================================
--- trunk/mapserver/mapwmslayer.c	2010-09-29 22:56:11 UTC (rev 10540)
+++ trunk/mapserver/mapwmslayer.c	2010-09-30 02:44:54 UTC (rev 10541)
@@ -1440,31 +1440,38 @@
     {
         FILE *fp;
         char szBuf[MS_BUFFER_LENGTH];
-
-        fp = fopen(pasReqInfo[iReq].pszOutputFile, "r");
-        if (fp)
+        
+        if( pasReqInfo[iReq].pszOutputFile )
         {
-            /* TODO: For now we'll only read the first chunk and return it
-             * via msSetError()... we should really try to parse the XML
-             * and extract the exception code/message though
-             */
-             size_t nSize;
-
-            nSize = fread(szBuf, sizeof(char), MS_BUFFER_LENGTH-1, fp);
-            if (nSize >= 0 && nSize < MS_BUFFER_LENGTH)
-                szBuf[nSize] = '\0';
+            fp = fopen(pasReqInfo[iReq].pszOutputFile, "r");
+            if (fp)
+            {
+                /* TODO: For now we'll only read the first chunk and return it
+                 * via msSetError()... we should really try to parse the XML
+                 * and extract the exception code/message though
+                 */
+                size_t nSize;
+                
+                nSize = fread(szBuf, sizeof(char), MS_BUFFER_LENGTH-1, fp);
+                if (nSize >= 0 && nSize < MS_BUFFER_LENGTH)
+                    szBuf[nSize] = '\0';
+                else
+                    strcpy(szBuf, "(!!!)"); /* This should never happen */
+                
+                fclose(fp);
+                
+                /* We're done with the remote server's response... delete it. */
+                if (!lp->debug)
+                    unlink(pasReqInfo[iReq].pszOutputFile);
+            }
             else
-                strcpy(szBuf, "(!!!)"); /* This should never happen */
-
-            fclose(fp);
-
-            /* We're done with the remote server's response... delete it. */
-            if (!lp->debug)
-                unlink(pasReqInfo[iReq].pszOutputFile);
+            {
+                strcpy(szBuf, "(Failed to open exception response)");
+            }
         }
         else
         {
-            strcpy(szBuf, "(Failed to open exception response)");
+            strncpy( szBuf, pasReqInfo[iReq].result_data, MS_BUFFER_LENGTH );
         }
 
         if (lp->debug)



More information about the mapserver-commits mailing list