[mapserver-commits] r7484 - branches/branch-5-0/mapserver

svn at osgeo.org svn at osgeo.org
Thu Mar 27 15:55:36 EDT 2008


Author: dmorissette
Date: 2008-03-27 15:55:36 -0400 (Thu, 27 Mar 2008)
New Revision: 7484

Modified:
   branches/branch-5-0/mapserver/HISTORY.TXT
   branches/branch-5-0/mapserver/mappostgis.c
Log:
Fixed handling of encrypted connection strings in postgis driver (#2563)


Modified: branches/branch-5-0/mapserver/HISTORY.TXT
===================================================================
--- branches/branch-5-0/mapserver/HISTORY.TXT	2008-03-27 19:39:31 UTC (rev 7483)
+++ branches/branch-5-0/mapserver/HISTORY.TXT	2008-03-27 19:55:36 UTC (rev 7484)
@@ -13,6 +13,8 @@
 Current Version (future 5.0.3, svn branch-5-0)
 ----------------------------------------------
 
+- Fixed handling of encrypted connection strings in postgis driver (#2563)
+
 - Fixed problem with large imagemaps generating no output (#2526)
 
 - Fixed problem with two division signs in an expression being treated

Modified: branches/branch-5-0/mapserver/mappostgis.c
===================================================================
--- branches/branch-5-0/mapserver/mappostgis.c	2008-03-27 19:39:31 UTC (rev 7483)
+++ branches/branch-5-0/mapserver/mappostgis.c	2008-03-27 19:55:36 UTC (rev 7484)
@@ -173,8 +173,6 @@
 {
     msPOSTGISLayerInfo  *layerinfo;
     int                 order_test = 1;
-    char                *index, *maskeddata;
-    int                 i, count;
 
     if(layer->debug) {
         msDebug("msPOSTGISLayerOpen called datastatement: %s\n", layer->data);
@@ -223,21 +221,22 @@
           return(MS_FAILURE);  /* An error should already have been produced */
         }
    
-        layerinfo->conn = PQconnectdb(layer->connection);
+        layerinfo->conn = PQconnectdb(conn_decrypted);
 
         msFree(conn_decrypted);
         conn_decrypted = NULL;
 
         if(!layerinfo->conn || PQstatus(layerinfo->conn) == CONNECTION_BAD) {
-            msDebug("FAILURE!!!");
-            maskeddata = (char *)malloc(strlen(layer->connection) + 1);
-            strcpy(maskeddata, layer->connection);
+            char *index, *maskeddata;
+            if (layer->debug)
+                msDebug("msPOSTGISLayerOpen() FAILURE!!!\n");
+
+            maskeddata = strdup(layer->connection);
             index = strstr(maskeddata, "password=");
             if(index != NULL) {
               index = (char *)(index + 9);
-              count = (int)(strstr(index, " ") - index);
-              for(i = 0; i < count; i++) {
-                  strncpy(index, "*", (int)1);
+              while(*index != '\0' && *index != ' ') {
+                  *index = '*';
                   index++;
               }
             }



More information about the mapserver-commits mailing list