Changeset: 8463ee758465 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8463ee758465
Modified Files:
        java/src/nl/cwi/monetdb/jdbc/MonetResultSet.java
Branch: Apr2011
Log Message:

getJavaDate: be more robust against invalid strings

The parsing position can be out of bounds when more data was expected.


diffs (26 lines):

diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetResultSet.java 
b/java/src/nl/cwi/monetdb/jdbc/MonetResultSet.java
--- a/java/src/nl/cwi/monetdb/jdbc/MonetResultSet.java
+++ b/java/src/nl/cwi/monetdb/jdbc/MonetResultSet.java
@@ -1674,10 +1674,18 @@
                }
                if (pdate == null) {
                        // parsing failed
-                       addWarning("parsing failed," +
-                                        " found: '" + 
monetDate.charAt(ppos.getErrorIndex()) + "'" +
-                                        " in: \"" + monetDate + "\"" +
-                                        " at pos: " + ppos.getErrorIndex());
+                       int epos = ppos.getErrorIndex();
+                       if (epos == -1) {
+                               addWarning("parsing '" + monetDate + "' 
failed");
+                       } else if (epos < monetDate.length()) {
+                               addWarning("parsing failed," +
+                                                " found: '" + 
monetDate.charAt(epos) + "'" +
+                                                " in: \"" + monetDate + "\"" +
+                                                " at pos: " + 
ppos.getErrorIndex());
+                       } else {
+                               addWarning("parsing failed, expected more data 
after '" +
+                                               monetDate + "'");
+                       }
                        // default value
                        cal.clear();
                        nanos = 0;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to