[Lada-commits] [PATCH] Avoid ISE if invalid datetime values are provided

Wald Commits scm-commit at wald.intevation.org
Fri Sep 30 11:15:48 CEST 2016


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1475226932 -7200
# Node ID 8d1df8f31475426eea5048e5ccbecabd4a637c64
# Parent  0a44ab47d3d5aa9e8f6dee4e7429e72d3094fab5
Avoid ISE if invalid datetime values are provided.

diff -r 0a44ab47d3d5 -r 8d1df8f31475 src/main/java/de/intevation/lada/rest/ProbeService.java
--- a/src/main/java/de/intevation/lada/rest/ProbeService.java	Fri Sep 30 10:59:18 2016 +0200
+++ b/src/main/java/de/intevation/lada/rest/ProbeService.java	Fri Sep 30 11:15:32 2016 +0200
@@ -367,8 +367,15 @@
         JsonObject object
     ) {
         String id = object.get("id").toString();
-        long start = object.getJsonNumber("start").longValue();
-        long end = object.getJsonNumber("end").longValue();
+        long start = 0;
+        long end = 0;
+        try {
+            start = object.getJsonNumber("start").longValue();
+            end = object.getJsonNumber("end").longValue();
+        } catch (ClassCastException e) {
+            // Catch invalid (i.e. too high) time values
+            return new Response(false, 612, null);
+        }
         if (start > end) {
             return new Response(false, 662, null);
         }


More information about the Lada-commits mailing list