]> granicus.if.org Git - postgis/commitdiff
Sanitize the connection string displayed in the GUI log (#356)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 23 Dec 2009 19:49:37 +0000 (19:49 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 23 Dec 2009 19:49:37 +0000 (19:49 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5052 b70326c6-7e19-0410-871a-916f4a2858ee

loader/shp2pgsql-gui.c

index 3285dd62e25238e5c7c6f83ecd1045cf1c8284d9..789f18b5ca4a8f5b4f5527360806263a3665ce60 100644 (file)
@@ -456,13 +456,26 @@ static void
 pgui_action_connection_test(GtkWidget *widget, gpointer data)
 {
        char *connection_string = NULL;
+       char *connection_sanitized = NULL;
+       char *ptr = NULL;
 
        if ( ! (connection_string = pgui_read_connection()) )
        {
                pgui_raise_error_dialogue();
                return;
        }
-       pgui_logf("Connecting: %s", connection_string);
+       
+       /* Clean the password out of the string before we display it. */
+       connection_sanitized = strdup(connection_string);
+       ptr = strstr(connection_sanitized, "password");
+       ptr += 9;
+       while( *ptr != ' ' && *ptr != '\0' )
+       {
+               *ptr = '*';
+               ptr++;
+       }
+       pgui_logf("Connecting: %s", connection_sanitized);
+       free(connection_sanitized);
 
        if ( pg_connection )
                PQfinish(pg_connection);