changeset 1068:8d1df8f31475

Avoid ISE if invalid datetime values are provided.
author Tom Gottfried <tom@intevation.de>
date Fri, 30 Sep 2016 11:15:32 +0200
parents 0a44ab47d3d5
children f78f90446084
files src/main/java/de/intevation/lada/rest/ProbeService.java
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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);
         }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)