[libpostgresql-jdbc-java] 36/128: make sure driver doesn't parse anything if the url isn't for us, also catch other possible errors, reported by Nathaniel Waisbrot

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:18:28 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to annotated tag REL9_3_1100
in repository libpostgresql-jdbc-java.

commit c531a34a2614db29fd98e37bbc72d87c5b8b17b7
Author: Dave Cramer <davecramer at gmail.com>
Date:   Mon Jan 28 16:52:56 2013 -0500

    make sure driver doesn't parse anything if the url isn't for us, also catch other possible errors, reported by Nathaniel Waisbrot
---
 org/postgresql/Driver.java.in | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/org/postgresql/Driver.java.in b/org/postgresql/Driver.java.in
index 27d8115..5f20a4e 100644
--- a/org/postgresql/Driver.java.in
+++ b/org/postgresql/Driver.java.in
@@ -227,6 +227,10 @@ public class Driver implements java.sql.Driver
     {
         // get defaults
         Properties defaults;
+
+        if (!url.startsWith("jdbc:postgresql:")) {
+            return null;
+        }
         try
         {
             defaults = getDefaultProperties();
@@ -239,12 +243,19 @@ public class Driver implements java.sql.Driver
 
         // override defaults with provided properties
         Properties props = new Properties(defaults);
-        for (Enumeration e = info.propertyNames(); e.hasMoreElements(); )
+        if (info != null)
         {
-            String propName = (String)e.nextElement();
-            props.setProperty(propName, info.getProperty(propName));
+            for (Enumeration e = info.propertyNames(); e.hasMoreElements(); )
+            {
+                String propName = (String)e.nextElement();
+                String propValue = info.getProperty(propName);
+                if ( propValue == null ) {
+                    throw new PSQLException(GT.tr("Properties for the driver contains a non-string value for the key ")+propName,
+                                            PSQLState.UNEXPECTED_ERROR);
+                }
+                props.setProperty( propName,propValue );
+            }
         }
-
         // parse URL and add more properties
         if ((props = parseURL(url, props)) == null)
         {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list